feat: новая архитектура UI и расширенная визуализация AIS

Архитектурные улучшения:
- Внедрен UIRenderingCoordinator с централизованным throttling
- Решены проблемы зависания UI через батчинг операций карты
- Добавлен VesselPathController для отслеживания маршрутов
- Реализован MapLibreMapImpl как альтернатива Яндекс.Картам

Визуализация AIS:
- Добавлены векторные иконки для всех типов судов
- Разделение Class A/B судов с соответствующими иконками
- Иконки навигационных статусов (anchor, moored, engine, sail)
- Улучшенный CursorOverlay с информацией о судах

Производительность:
- Throttling UI обновлений (vessel: 500ms, AIS: 1s, paths: 2s)
- Устранение утечек Handler объектов
- Оптимизация GeoJSON операций в MapLibre
This commit is contained in:
2025-10-02 09:15:33 +03:00
parent 41432665ea
commit b5aee265bc
85 changed files with 7132 additions and 449 deletions
+3
View File
@@ -53,6 +53,9 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime:2.8.3'
implementation 'androidx.lifecycle:lifecycle-livedata:2.8.3'
// MapLibre GL Android SDK (используем только один артефакт, без плагина аннотаций)
implementation group: 'org.maplibre.gl', name: 'android-sdk-opengl', version: '11.13.5'
// Тестирование
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+5 -1
View File
@@ -11,6 +11,9 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<!-- Разрешение на уведомления (Android 13+) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- Разрешения для интернета (для Яндекс.Карт) -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@@ -44,7 +47,8 @@
android:name=".MainActivity"
android:exported="true"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@style/Theme.AISMap">
android:theme="@style/Theme.AISMap"
android:keepScreenOn="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.grigowashere.aismap.data.Repository;
import com.grigowashere.aismap.data.entity.AISVesselEntity;
import com.grigowashere.aismap.data.entity.VesselEntity;
import java.util.ArrayList;
import java.util.List;
@@ -25,6 +26,12 @@ public class AisTargetsActivity extends AppCompatActivity implements AisTargetsA
private android.os.Handler tickerHandler;
private Runnable tickerRunnable;
private android.widget.TextView textEmptyState;
private android.widget.TextView textTargetCount;
// Данные нашего корабля
private double ourLatitude = 0;
private double ourLongitude = 0;
private double ourCourse = 0;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -33,8 +40,12 @@ public class AisTargetsActivity extends AppCompatActivity implements AisTargetsA
repository = new Repository(this);
// Загружаем данные нашего корабля
loadOurVesselData();
recyclerView = findViewById(R.id.recycler_ais_targets);
textEmptyState = findViewById(R.id.text_empty_state);
textTargetCount = findViewById(R.id.text_target_count);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter = new AisTargetsAdapter(new ArrayList<>(), this);
recyclerView.setAdapter(adapter);
@@ -48,6 +59,13 @@ public class AisTargetsActivity extends AppCompatActivity implements AisTargetsA
}
adapter.submitList(entities);
// Обновляем данные нашего корабля в адаптере
adapter.updateOurVesselData(ourLatitude, ourLongitude, ourCourse);
// Обновляем счетчик целей
int targetCount = entities != null ? entities.size() : 0;
textTargetCount.setText("AIS цели: " + targetCount);
// Показываем/скрываем сообщение о пустом состоянии
if (entities == null || entities.isEmpty()) {
textEmptyState.setVisibility(android.view.View.VISIBLE);
@@ -77,6 +95,36 @@ public class AisTargetsActivity extends AppCompatActivity implements AisTargetsA
};
tickerHandler.postDelayed(tickerRunnable, 1000);
}
private void loadOurVesselData() {
repository.getLatestOwnVesselAsync(new Repository.RepositoryCallback<VesselEntity>() {
@Override
public void onComplete(VesselEntity ourVessel) {
// Переносим на UI поток для безопасности
AisTargetsActivity.this.runOnUiThread(() -> {
if (ourVessel != null) {
ourLatitude = ourVessel.latitude;
ourLongitude = ourVessel.longitude;
ourCourse = ourVessel.course;
android.util.Log.i("AisTargetsActivity", "Данные нашего корабля загружены: lat=" + ourLatitude +
", lon=" + ourLongitude + ", course=" + ourCourse);
// Обновляем адаптер с новыми данными
if (adapter != null) {
adapter.updateOurVesselData(ourLatitude, ourLongitude, ourCourse);
}
} else {
android.util.Log.w("AisTargetsActivity", "Данные нашего корабля не найдены в БД");
}
});
}
@Override
public void onError(Exception e) {
android.util.Log.e("AisTargetsActivity", "Ошибка загрузки данных нашего корабля: " + e.getMessage(), e);
}
});
}
@Override
public void onMarinetrafficClick(String mmsi) {
@@ -12,6 +12,7 @@ import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import com.grigowashere.aismap.data.entity.AISVesselEntity;
import com.grigowashere.aismap.utils.NavigationUtils;
class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.ViewHolder> {
@@ -21,6 +22,9 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
}
private final OnItemClickListener listener;
private double ourLatitude = 0;
private double ourLongitude = 0;
private double ourCourse = 0;
protected AisTargetsAdapter(@NonNull DiffUtil.ItemCallback<AISVesselEntity> diffCallback, OnItemClickListener listener) {
super(diffCallback);
@@ -31,6 +35,12 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
this(DIFF_CALLBACK, listener);
submitList(initial);
}
public void updateOurVesselData(double latitude, double longitude, double course) {
this.ourLatitude = latitude;
this.ourLongitude = longitude;
this.ourCourse = course;
}
static final DiffUtil.ItemCallback<AISVesselEntity> DIFF_CALLBACK = new DiffUtil.ItemCallback<AISVesselEntity>() {
@Override
@@ -59,7 +69,7 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
AISVesselEntity item = getItem(position);
holder.bind(item, listener);
holder.bind(item, listener, ourLatitude, ourLongitude, ourCourse);
}
@Override
@@ -69,7 +79,7 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
} else {
// Частичное обновление только времени
AISVesselEntity item = getItem(position);
holder.updateTimeOnly(item);
holder.updateTimeOnly(item, ourLatitude, ourLongitude, ourCourse);
}
}
@@ -80,6 +90,8 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
TextView tvCourseSpeed;
TextView tvLastUpdate;
TextView tvTimeAgo;
TextView tvDistance;
TextView tvBearing;
Button btnMarineTraffic;
Button btnCenterOnMap;
@@ -91,16 +103,32 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
tvCourseSpeed = itemView.findViewById(R.id.tv_course_speed);
tvLastUpdate = itemView.findViewById(R.id.tv_last_update);
tvTimeAgo = itemView.findViewById(R.id.tv_time_ago);
tvDistance = itemView.findViewById(R.id.tv_distance);
tvBearing = itemView.findViewById(R.id.tv_bearing);
btnMarineTraffic = itemView.findViewById(R.id.btn_marine_traffic);
btnCenterOnMap = itemView.findViewById(R.id.btn_center_on_map);
}
void bind(AISVesselEntity entity, OnItemClickListener listener) {
void bind(AISVesselEntity entity, OnItemClickListener listener, double ourLat, double ourLon, double ourCourse) {
String name = entity.vesselName != null && !entity.vesselName.isEmpty() ? entity.vesselName : "MMSI " + entity.mmsi;
tvTitle.setText(name);
tvMmsi.setText("MMSI: " + entity.mmsi);
tvCoords.setText(String.format(java.util.Locale.getDefault(), "%.6f, %.6f", entity.latitude, entity.longitude));
tvCourseSpeed.setText(String.format(java.util.Locale.getDefault(), "COG %.1f° • %.1f kn", entity.course, entity.speed));
// Вычисляем расстояние и азимут
if (ourLat != 0 && ourLon != 0 && entity.latitude != 0 && entity.longitude != 0) {
double distance = NavigationUtils.calculateDistance(ourLat, ourLon, entity.latitude, entity.longitude);
double bearing = NavigationUtils.calculateBearing(ourLat, ourLon, entity.latitude, entity.longitude);
double relativeBearing = NavigationUtils.calculateRelativeBearing(ourCourse, bearing);
tvDistance.setText("Расстояние: " + NavigationUtils.formatDistance(distance));
tvBearing.setText("Азимут: " + NavigationUtils.formatRelativeBearing(relativeBearing));
} else {
tvDistance.setText("Расстояние: --");
tvBearing.setText("Азимут: --");
}
// Время последнего обновления и ago
if (entity.lastUpdateEpochMs > 0) {
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss", java.util.Locale.getDefault());
@@ -119,7 +147,7 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
});
}
void updateTimeOnly(AISVesselEntity entity) {
void updateTimeOnly(AISVesselEntity entity, double ourLat, double ourLon, double ourCourse) {
// Обновляем только поля времени, чтобы избежать мигания всего элемента
if (entity.lastUpdateEpochMs > 0) {
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss", java.util.Locale.getDefault());
@@ -131,6 +159,19 @@ class AisTargetsAdapter extends ListAdapter<AISVesselEntity, AisTargetsAdapter.V
tvLastUpdate.setText("Обновлено: --");
tvTimeAgo.setText("-- сек назад");
}
// Также обновляем расстояние и азимут при обновлении времени
if (ourLat != 0 && ourLon != 0 && entity.latitude != 0 && entity.longitude != 0) {
double distance = NavigationUtils.calculateDistance(ourLat, ourLon, entity.latitude, entity.longitude);
double bearing = NavigationUtils.calculateBearing(ourLat, ourLon, entity.latitude, entity.longitude);
double relativeBearing = NavigationUtils.calculateRelativeBearing(ourCourse, bearing);
tvDistance.setText("Расстояние: " + NavigationUtils.formatDistance(distance));
tvBearing.setText("Азимут: " + NavigationUtils.formatRelativeBearing(relativeBearing));
} else {
tvDistance.setText("Расстояние: --");
tvBearing.setText("Азимут: --");
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -37,8 +37,19 @@ public class SettingsActivity extends AppCompatActivity {
private EditText etStaleRemoveMinutes;
private SwitchMaterial switchVibrationEnabled;
private SwitchMaterial switchSoundEnabled;
private SwitchMaterial switchKeepScreenOn;
private SwitchMaterial switchCursorEnabled;
private Button btnCancel;
private Button btnSave;
private Button btnClearPath;
// Path/prediction
private EditText etPathMaxPoints;
private EditText etPathWidth;
private EditText etPathColor;
private EditText etPredictionWidth;
private EditText etPredictionColor;
private EditText etPredictionHorizon;
// Состояние настроек до изменений
private int originalUDPPort;
@@ -50,6 +61,8 @@ public class SettingsActivity extends AppCompatActivity {
private int originalStaleRemoveMinutes;
private boolean originalVibrationEnabled;
private boolean originalSoundEnabled;
private boolean originalKeepScreenOnEnabled;
private boolean originalCursorEnabled;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -90,8 +103,18 @@ public class SettingsActivity extends AppCompatActivity {
etStaleRemoveMinutes = findViewById(R.id.et_stale_remove_minutes);
switchVibrationEnabled = findViewById(R.id.switch_vibration_enabled);
switchSoundEnabled = findViewById(R.id.switch_sound_enabled);
switchKeepScreenOn = findViewById(R.id.switch_keep_screen_on);
switchCursorEnabled = findViewById(R.id.switch_cursor_enabled);
btnCancel = findViewById(R.id.btn_cancel);
btnSave = findViewById(R.id.btn_save);
btnClearPath = findViewById(R.id.btn_clear_path);
etPathMaxPoints = findViewById(R.id.et_path_max_points);
etPathWidth = findViewById(R.id.et_path_width);
etPathColor = findViewById(R.id.et_path_color);
etPredictionWidth = findViewById(R.id.et_prediction_width);
etPredictionColor = findViewById(R.id.et_prediction_color);
etPredictionHorizon = findViewById(R.id.et_prediction_horizon_sec);
}
/**
@@ -128,6 +151,20 @@ public class SettingsActivity extends AppCompatActivity {
switchVibrationEnabled.setChecked(settingsManager.isVibrationEnabled());
switchSoundEnabled.setChecked(settingsManager.isSoundEnabled());
// Настройки экрана
switchKeepScreenOn.setChecked(settingsManager.isKeepScreenOnEnabled());
// Настройки курсора
switchCursorEnabled.setChecked(settingsManager.isCursorEnabled());
// Путь и предсказание
etPathMaxPoints.setText(String.valueOf(settingsManager.getPathMaxPoints()));
etPathWidth.setText(String.valueOf(settingsManager.getPathWidth()));
etPathColor.setText(String.format("#%06X", (0xFFFFFF & settingsManager.getPathColor())));
etPredictionWidth.setText(String.valueOf(settingsManager.getPredictionWidth()));
etPredictionColor.setText(String.format("#%06X", (0xFFFFFF & settingsManager.getPredictionColor())));
etPredictionHorizon.setText(String.valueOf(settingsManager.getPredictionHorizonSec()));
Log.i(TAG, "Настройки загружены в UI");
}
@@ -144,6 +181,8 @@ public class SettingsActivity extends AppCompatActivity {
originalStaleRemoveMinutes = settingsManager.getDataStaleRemoveMinutes();
originalVibrationEnabled = settingsManager.isVibrationEnabled();
originalSoundEnabled = settingsManager.isSoundEnabled();
originalKeepScreenOnEnabled = settingsManager.isKeepScreenOnEnabled();
originalCursorEnabled = settingsManager.isCursorEnabled();
Log.i(TAG, "Оригинальные настройки сохранены");
}
@@ -164,6 +203,12 @@ public class SettingsActivity extends AppCompatActivity {
saveSettings();
});
// Кнопка очистки пути
btnClearPath.setOnClickListener(v -> {
Log.i(TAG, "Нажата кнопка очистки пути");
clearVesselPath();
});
// Обработчик изменения режима данных
radioGroupDataMode.setOnCheckedChangeListener((group, checkedId) -> {
updateDataModeDescription();
@@ -268,6 +313,16 @@ public class SettingsActivity extends AppCompatActivity {
settingsManager.setDataStaleRemoveMinutes(staleRemoveMinutes);
settingsManager.setVibrationEnabled(switchVibrationEnabled.isChecked());
settingsManager.setSoundEnabled(switchSoundEnabled.isChecked());
settingsManager.setKeepScreenOnEnabled(switchKeepScreenOn.isChecked());
settingsManager.setCursorEnabled(switchCursorEnabled.isChecked());
// Путь и предсказание
try { settingsManager.setPathMaxPoints(Integer.parseInt(etPathMaxPoints.getText().toString().trim())); } catch (Exception ignored) {}
try { settingsManager.setPathWidth(Float.parseFloat(etPathWidth.getText().toString().trim())); } catch (Exception ignored) {}
try { settingsManager.setPathColor(parseColor(etPathColor.getText().toString().trim(), settingsManager.getPathColor())); } catch (Exception ignored) {}
try { settingsManager.setPredictionWidth(Float.parseFloat(etPredictionWidth.getText().toString().trim())); } catch (Exception ignored) {}
try { settingsManager.setPredictionColor(parseColor(etPredictionColor.getText().toString().trim(), settingsManager.getPredictionColor())); } catch (Exception ignored) {}
try { settingsManager.setPredictionHorizonSec(Integer.parseInt(etPredictionHorizon.getText().toString().trim())); } catch (Exception ignored) {}
Log.i(TAG, "Настройки сохранены: " + settingsManager.getSettingsSummary());
@@ -283,6 +338,7 @@ public class SettingsActivity extends AppCompatActivity {
resultIntent.putExtra("android_nmea_enabled", switchAndroidNMEAEnabled.isChecked());
resultIntent.putExtra("udp_nmea_enabled", switchUDPNMEAEnabled.isChecked());
resultIntent.putExtra("data_mode", dataMode);
resultIntent.putExtra("cursor_enabled", switchCursorEnabled.isChecked());
setResult(RESULT_OK, resultIntent);
@@ -294,6 +350,20 @@ public class SettingsActivity extends AppCompatActivity {
Toast.makeText(this, "Ошибка при сохранении настроек", Toast.LENGTH_SHORT).show();
}
}
private int parseColor(String text, int fallback) {
try {
if (text == null || text.isEmpty()) return fallback;
String s = text.startsWith("#") ? text : ("#" + text);
// добавим полную непрозрачность если пришёл #RRGGBB
if (s.length() == 7) {
s = "#FF" + s.substring(1);
}
return (int) Long.parseLong(s.substring(1), 16);
} catch (Exception e) {
return fallback;
}
}
/**
* Получает выбранный режим данных
@@ -378,6 +448,28 @@ public class SettingsActivity extends AppCompatActivity {
settingsManager.shouldRestartNMEA(originalAndroidNMEAEnabled, originalUDPNMEAEnabled, originalDataMode);
}
/**
* Очищает трекер пути собственного судна
*/
private void clearVesselPath() {
try {
// Создаем интент для уведомления MainActivity об очистке пути
Intent resultIntent = new Intent();
resultIntent.putExtra("clear_vessel_path", true);
setResult(RESULT_OK, resultIntent);
Toast.makeText(this, "Трекер пути будет очищен", Toast.LENGTH_SHORT).show();
Log.i(TAG, "Запрошена очистка трекера пути");
// Закрываем SettingsActivity чтобы передать результат в MainActivity
finish();
} catch (Exception e) {
Log.e(TAG, "Ошибка при очистке пути: " + e.getMessage(), e);
Toast.makeText(this, "Ошибка при очистке пути", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onBackPressed() {
Log.i(TAG, "Нажата кнопка назад");
@@ -8,8 +8,12 @@ import com.grigowashere.aismap.maps.MapInterface;
import com.grigowashere.aismap.data.Repository;
import com.grigowashere.aismap.data.mapper.AISVesselMapper;
import com.grigowashere.aismap.services.NotificationService;
import com.grigowashere.aismap.utils.SettingsManager;
import com.grigowashere.aismap.ui.UIDataChangeNotifier;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -39,6 +43,10 @@ public class AppController implements
private ExecutorService executor;
private com.grigowashere.aismap.data.Repository repository;
private NotificationService notificationService;
private SettingsManager settingsManager;
private VesselPathController pathController;
// VesselPathController для каждого AIS судна (ключ: MMSI)
private final Map<String, VesselPathController> aisPathControllers = new HashMap<>();
private boolean isUDPEnabled;
private boolean isAndroidNMEAEnabled;
@@ -56,9 +64,18 @@ public class AppController implements
private Runnable dbCleanupRunnable;
private static final long DB_CLEANUP_INTERVAL = 60000; // 1 минута
// Callback для обновления UI
// Единый Handler для всех UI операций (предотвращение утечек Handler'ов)
private android.os.Handler uiHandler;
// Индикаторы UI данных для централизованного throttling
private UIDataChangeNotifier uiDataNotifier;
// Callback для обновления UI (legacy для MainActivity)
private UIUpdateCallback uiUpdateCallback;
// Диагностика сервисов
private long lastServiceLogTime = 0;
public interface UIUpdateCallback {
void onVesselPositionUpdated(Vessel vessel);
void onGPSQualityUpdated(Vessel vessel);
@@ -80,11 +97,16 @@ public class AppController implements
this.executor = Executors.newCachedThreadPool();
this.repository = new com.grigowashere.aismap.data.Repository(context);
this.notificationService = new NotificationService(context);
this.settingsManager = new SettingsManager(context);
this.pathController = new VesselPathController(context, settingsManager);
// Инициализируем Handler для периодической очистки БД
this.dbCleanupHandler = new android.os.Handler(android.os.Looper.getMainLooper());
this.dbCleanupRunnable = this::performDatabaseCleanup;
// Инициализируем единый UI Handler
this.uiHandler = new android.os.Handler(android.os.Looper.getMainLooper());
initializeControllers();
}
@@ -113,28 +135,54 @@ public class AppController implements
androidNmeaListener = new AndroidNMEAListener(context);
androidNmeaListener.setCallback(this);
// Восстанавливаем данные из БД при старте
try {
com.grigowashere.aismap.data.entity.VesselEntity latest = repository.getLatestOwnVesselSync();
if (latest != null) {
ownVessel.setLatitude(latest.latitude);
ownVessel.setLongitude(latest.longitude);
ownVessel.setAccuracy(latest.accuracy);
ownVessel.setFixTime(latest.fixTime);
}
java.util.List<com.grigowashere.aismap.data.entity.AISVesselEntity> list = repository.getAllAISSync();
if (list != null) {
for (com.grigowashere.aismap.data.entity.AISVesselEntity entity : list) {
// Используем маппер для полного восстановления всех полей
AISVessel vessel = AISVesselMapper.toModel(entity);
aisVessels.add(vessel);
Log.d(TAG, "AIS судно восстановлено из БД с полными данными: " + vessel.getMmsi());
// Восстанавливаем данные из БД при старте АСИНХРОННО
Log.i(TAG, "🔄 Запускаем асинхронное восстановление данных из БД...");
executor.execute(() -> {
try {
Log.d(TAG, "📊 Загружаем данные судна из БД...");
com.grigowashere.aismap.data.entity.VesselEntity latest = repository.getLatestOwnVesselSync();
if (latest != null) {
ownVessel.setLatitude(latest.latitude);
ownVessel.setLongitude(latest.longitude);
ownVessel.setAccuracy(latest.accuracy);
ownVessel.setFixTime(latest.fixTime);
Log.d(TAG, "✅ Данные судна восстановлены: " + latest.latitude + "," + latest.longitude);
} else {
Log.d(TAG, "ℹ️ Нет данных судна в БД");
}
Log.i(TAG, "Восстановлено " + list.size() + " AIS судов из БД с полными данными");
Log.d(TAG, "🚢 Загружаем AIS суда из БД...");
java.util.List<com.grigowashere.aismap.data.entity.AISVesselEntity> list = repository.getAllAISSync();
if (list != null && !list.isEmpty()) {
synchronized (aisVessels) {
aisVessels.clear(); // Очищаем перед восстановлением
for (com.grigowashere.aismap.data.entity.AISVesselEntity entity : list) {
// Используем маппер для полного восстановления всех полей
AISVessel vessel = AISVesselMapper.toModel(entity);
aisVessels.add(vessel);
Log.d(TAG, "AIS судно восстановлено из БД с полными данными: " + vessel.getMmsi());
}
}
Log.i(TAG, "✅ Восстановлено " + list.size() + " AIS судов из БД с полными данными");
} else {
Log.d(TAG, "ℹ️ Нет AIS судов в БД");
}
// Уведомляем UI о восстановлении данных (если mapInterface уже установлен)
uiHandler.post(() -> {
if (mapInterface != null) {
Log.i(TAG, "🔄 Уведомляем UI о восстановленных данных...");
// Восстановление маркеров будет выполнено через setMapInterface()
// когда он будет вызван из MainActivity
} else {
Log.d(TAG, "⏳ mapInterface еще не установлен, восстановление отложено");
}
});
} catch (Exception e) {
Log.e(TAG, "❌ Ошибка восстановления данных из БД: " + e.getMessage(), e);
}
} catch (Exception e) {
Log.e(TAG, "Ошибка восстановления данных из БД: " + e.getMessage(), e);
}
});
}
/**
@@ -148,28 +196,45 @@ public class AppController implements
mapInterface.setMarkerClickListener(this);
Log.i(TAG, "MarkerClickListener установлен, теперь можно создавать маркеры");
// Восстановление отрисовки сохранённых данных на карте
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
try {
// Позиция нашего судна
if (ownVessel != null && ownVessel.getLatitude() != 0 && ownVessel.getLongitude() != 0) {
mapInterface.updateOwnVesselPosition(ownVessel);
}
// AIS маркеры
if (aisVessels != null && !aisVessels.isEmpty()) {
for (AISVessel v : aisVessels) {
mapInterface.addAISVesselMarker(v);
}
}
} catch (Exception e) {
Log.e(TAG, "Ошибка восстановления отрисовки на карте: " + e.getMessage(), e);
// Уведомляем UI Coordinator о восстановлении данных
if (uiDataNotifier != null) {
Log.i(TAG, "🔄 Восстановление данных через UI Coordinator");
// Восстанавливаем позицию собственного судна
if (ownVessel != null && ownVessel.getLatitude() != 0 && ownVessel.getLongitude() != 0) {
Log.i(TAG, "📍 Восстанавливаем позицию судна: " + ownVessel.getLatitude() + "," + ownVessel.getLongitude());
uiDataNotifier.onVesselPositionChanged(ownVessel);
} else {
Log.w(TAG, "⚠️ Судно не имеет валидных координат для восстановления");
}
});
// Восстанавливаем AIS суда
if (aisVessels != null && !aisVessels.isEmpty()) {
Log.i(TAG, "🚢 Восстанавливаем " + aisVessels.size() + " AIS судов");
for (AISVessel v : aisVessels) {
Log.d(TAG, " - AIS судно: " + v.getMmsi() + " на " + v.getLatitude() + "," + v.getLongitude());
uiDataNotifier.onAISVesselChanged(v);
}
Log.i(TAG, "" + aisVessels.size() + " AIS судов отправлено в UI Coordinator");
} else {
Log.i(TAG, "ℹ️ Нет AIS судов для восстановления");
}
} else {
Log.w(TAG, "❌ uiDataNotifier не установлен при восстановлении данных - маркеры НЕ будут восстановлены!");
}
}
}
/**
* Устанавливает callback для обновления UI
* Устанавливает индикатор изменений данных для централизованного UI throttling
*/
public void setUIDataChangeNotifier(UIDataChangeNotifier notifier) {
this.uiDataNotifier = notifier;
Log.i(TAG, "UIDataChangeNotifier установлен: " + (notifier != null ? "success" : "null"));
}
/**
* Устанавливает callback для обновления UI (legacy для MainActivity)
*/
public void setUIUpdateCallback(UIUpdateCallback callback) {
this.uiUpdateCallback = callback;
@@ -344,6 +409,18 @@ public class AppController implements
ownVessel.setFixTime(vessel.getFixTime());
ownVessel.setFixQuality(vessel.getFixQuality());
// Добавляем точку в путь судна
if (pathController != null) {
boolean pointAdded = pathController.addPathPoint(
vessel.getLongitude(),
vessel.getLatitude(),
(float) ownVessel.getSpeed()
);
if (pointAdded) {
Log.d(TAG, "Точка пути добавлена из GPS: " + pathController.getPathPointsCount() + " точек");
}
}
// Сохраняем позицию в локальную БД
try {
com.grigowashere.aismap.data.entity.VesselEntity ve = new com.grigowashere.aismap.data.entity.VesselEntity();
@@ -361,19 +438,12 @@ public class AppController implements
uiUpdateCallback.onVesselPositionUpdated(ownVessel);
}
// Обновляем карту в главном потоке с throttling
if (mapInterface != null) {
Log.i(TAG, "Обновляем позицию на карте...");
// Используем postDelayed для предотвращения частых обновлений
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
try {
Log.i(TAG, "Вызываем mapInterface.updateOwnVesselPosition...");
mapInterface.updateOwnVesselPosition(ownVessel);
Log.i(TAG, "Позиция на карте обновлена");
} catch (Exception e) {
Log.e(TAG, "Ошибка обновления позиции на карте: " + e.getMessage(), e);
}
}, 100); // Задержка 100мс для throttling
// Уведомляем UI Coordinator об изменении позиции судна (централизованный throttling)
if (uiDataNotifier != null) {
Log.d(TAG, "Уведомляем UI Coordinator об изменении позиции судна");
uiDataNotifier.onVesselPositionChanged(ownVessel);
} else {
Log.w(TAG, "uiDataNotifier не установлен, пропускаем UI обновление");
}
}
@@ -386,17 +456,23 @@ public class AppController implements
@Override
public void onVesselUpdated(Vessel vessel) {
Log.i(TAG, "🔄 onVesselUpdated вызван: lat=" + vessel.getLatitude() +
", lon=" + vessel.getLongitude() +
", course=" + vessel.getCourse() +
", speed=" + vessel.getSpeed());
// Сокращаем шум логов: подробности обновления судна убраны
// Обновляем координаты, если они есть (для режима "только NMEA")
if (vessel.getLatitude() != 0 && vessel.getLongitude() != 0) {
ownVessel.setLatitude(vessel.getLatitude());
ownVessel.setLongitude(vessel.getLongitude());
Log.i(TAG, "📍 Координаты обновлены из NMEA: lat=" + vessel.getLatitude() +
", lon=" + vessel.getLongitude());
// Сокращаем шум логов: координаты обновлены (без детализации)
// Добавляем точку в путь судна
if (pathController != null) {
boolean pointAdded = pathController.addPathPoint(
vessel.getLongitude(),
vessel.getLatitude(),
(float) vessel.getSpeed()
);
// Убираем лог о добавлении каждой точки пути
}
}
// Обновляем дополнительные данные
@@ -414,18 +490,14 @@ public class AppController implements
ownVessel.setAltitude(vessel.getAltitude());
}
Log.i(TAG, "NMEA данные обновлены: course=" + vessel.getCourse() +
", speed=" + vessel.getSpeed() +
", satellites=" + vessel.getSatellites());
// Сокращаем шум логов: сводка NMEA обновлений убрана
// Обновляем карту в главном потоке
if (mapInterface != null) {
Log.i(TAG, "Обновляем позицию на карте из NMEA...");
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
// Сокращаем шум логов: убираем информационные логи карты
uiHandler.post(() -> {
try {
Log.i(TAG, "Вызываем mapInterface.updateOwnVesselPosition из NMEA...");
mapInterface.updateOwnVesselPosition(ownVessel);
Log.i(TAG, "Позиция на карте обновлена из NMEA");
} catch (Exception e) {
Log.e(TAG, "Ошибка обновления позиции на карте из NMEA: " + e.getMessage(), e);
}
@@ -440,7 +512,7 @@ public class AppController implements
@Override
public void onDOPUpdated(double pdop, double hdop, double vdop) {
Log.i(TAG, "📊 DOP обновлен: PDOP=" + pdop + ", HDOP=" + hdop + ", VDOP=" + vdop);
// Убираем шумный лог DOP обновлений
// Обновляем DOP значения
ownVessel.setPdop(pdop);
@@ -486,15 +558,15 @@ public class AppController implements
Log.e(TAG, "Ошибка апсерта AIS в БД: " + e.getMessage(), e);
}
if (mapInterface != null) {
// Используем Handler для выполнения в главном потоке
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
try {
mapInterface.updateAISVesselPosition(existingVessel);
} catch (Exception e) {
Log.e(TAG, "Ошибка обновления позиции AIS судна на карте: " + e.getMessage(), e);
}
});
// Добавляем точку в путь AIS судна
addAISVesselPathPoint(existingVessel);
// Уведомляем UI Coordinator об обновлении AIS судна
if (uiDataNotifier != null) {
Log.d(TAG, "Уведомляем UI Coordinator об обновлении AIS судна: " + existingVessel.getMmsi());
uiDataNotifier.onAISVesselChanged(existingVessel);
} else {
Log.w(TAG, "uiDataNotifier не установлен, пропускаем AIS обновление");
}
} else {
// Добавляем новое судно
@@ -522,15 +594,15 @@ public class AppController implements
Log.e(TAG, "Ошибка апсерта AIS в БД: " + e.getMessage(), e);
}
if (mapInterface != null) {
// Используем Handler для выполнения в главном потоке
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
try {
mapInterface.addAISVesselMarker(vessel);
} catch (Exception e) {
Log.e(TAG, "Ошибка добавления AIS судна на карту: " + e.getMessage(), e);
}
});
// Добавляем точку в путь нового AIS судна
addAISVesselPathPoint(vessel);
// Уведомляем UI Coordinator о новом AIS судне
if (uiDataNotifier != null) {
Log.d(TAG, "Уведомляем UI Coordinator о новом AIS судне: " + vessel.getMmsi());
uiDataNotifier.onAISVesselChanged(vessel);
} else {
Log.w(TAG, "uiDataNotifier не установлен, пропускаем добавление AIS судна");
}
}
@@ -553,7 +625,8 @@ public class AppController implements
float azimuth = (float) ownVessel.getCourse();
List<AISVessel> nearbyVessels = getNearbyVessels();
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
// Используем существующий uiHandler вместо создания нового
uiHandler.post(() -> {
((ExtendedUIUpdateCallback) uiUpdateCallback).onUpdateCompass(azimuth, nearbyVessels);
});
}
@@ -580,11 +653,29 @@ public class AppController implements
@Override
public void onDataReceived(String data, String sourceAddress, int sourcePort) {
Log.d(TAG, "UDP данные получены от " + sourceAddress + ":" + sourcePort);
// Диагностика: логируем каждые 10 секунд
long now = System.currentTimeMillis();
if (now - lastServiceLogTime > 10000) {
Log.d(TAG, "📡 AppController: UDP данные получены от " + sourceAddress + ":" + sourcePort);
lastServiceLogTime = now;
}
// Парсим полученные данные как NMEA
nmeaParser.parseNMEA(data);
// Обновляем метки времени по префиксу
// Парсим полученные данные как NMEA В ФОНОВОМ ПОТОКЕ
executor.execute(() -> {
try {
nmeaParser.parseNMEA(data);
// Диагностика: логируем каждые 10 секунд
long now2 = System.currentTimeMillis();
if (now2 - lastServiceLogTime > 10000) {
Log.d(TAG, "✅ AppController: UDP NMEA обработано в фоновом потоке");
lastServiceLogTime = now2;
}
} catch (Exception e) {
Log.e(TAG, "❌ Ошибка парсинга UDP NMEA в фоновом потоке: " + e.getMessage(), e);
}
});
// Обновляем метки времени по префиксу в UI потоке (быстрая операция)
updateLastMessageAgesFromRaw(data);
}
@@ -602,19 +693,38 @@ public class AppController implements
@Override
public void onNMEAMessage(String message, long timestamp) {
Log.i(TAG, "📱 Android NMEA сообщение получено в AppController: " + message);
// Диагностика: логируем каждые 10 секунд
long now = System.currentTimeMillis();
if (now - lastServiceLogTime > 10000) {
Log.d(TAG, "📱 AppController: Android NMEA сообщение получено");
lastServiceLogTime = now;
}
// Парсим полученные данные как NMEA
nmeaParser.parseNMEA(message);
// Парсим полученные данные как NMEA В ФОНОВОМ ПОТОКЕ
executor.execute(() -> {
try {
nmeaParser.parseNMEA(message);
// Диагностика: логируем каждые 10 секунд
long now2 = System.currentTimeMillis();
if (now2 - lastServiceLogTime > 10000) {
Log.d(TAG, "✅ AppController: NMEA обработано в фоновом потоке");
lastServiceLogTime = now2;
}
} catch (Exception e) {
Log.e(TAG, "❌ Ошибка парсинга NMEA в фоновом потоке: " + e.getMessage(), e);
}
});
// Обновляем метки времени в UI потоке (быстрая операция)
if (message != null) {
String trimmed = message.trim();
if (!trimmed.isEmpty()) {
char c = trimmed.charAt(0);
long now = android.os.SystemClock.elapsedRealtime();
long now3 = android.os.SystemClock.elapsedRealtime();
if (c == '$') {
lastGPSMessageRealtimeMs = now;
lastGPSMessageRealtimeMs = now3;
} else if (c == '!') {
lastAISMessageRealtimeMs = now;
lastAISMessageRealtimeMs = now3;
}
}
}
@@ -681,32 +791,38 @@ public class AppController implements
* Очищает все AIS суда
*/
public void clearAISVessels() {
Log.i(TAG, "Очищаем AIS суда из контроллера");
// Очищаем локальные данные
aisVessels.clear();
if (mapInterface != null) {
// Используем Handler для выполнения в главном потоке
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
try {
mapInterface.clearAISVesselMarkers();
} catch (Exception e) {
Log.e(TAG, "Ошибка очистки AIS судов на карте: " + e.getMessage(), e);
}
});
// Уведомляем UI Coordinator о необходимости очистки карты
if (uiDataNotifier != null) {
Log.d(TAG, "Уведомляем UI Coordinator об очистке AIS судов");
// TODO: Добавить метод очистки всех AIS судов в UIDataChangeNotifier
// Пока что очищаем через individual removals
Log.i(TAG, "Individual AIS removal через uiDataNotifier еще не реализован");
} else {
Log.w(TAG, "uiDataNotifier не установлен, очистка AIS судов пропущена");
}
// Очищаем AIS path controllers
aisPathControllers.clear();
}
/**
* Центрирует карту на позиции нашего судна
*/
public void centerOnOwnVessel() {
if (mapInterface != null && ownVessel != null) {
// Используем Handler для выполнения в главном потоке
new android.os.Handler(android.os.Looper.getMainLooper()).post(() -> {
try {
mapInterface.centerOnPosition(ownVessel.getLatitude(), ownVessel.getLongitude());
} catch (Exception e) {
Log.e(TAG, "Ошибка центрирования карты: " + e.getMessage(), e);
}
});
if (ownVessel != null) {
Log.d(TAG, "Запрос центрирования карты на судне: " + ownVessel.getLatitude() + "," + ownVessel.getLongitude());
// Уведомляем UI Coordinator о необходимости центрирования карты
if (uiDataNotifier != null) {
uiDataNotifier.onRequestCenterMap(ownVessel.getLatitude(), ownVessel.getLongitude());
} else {
Log.w(TAG, "uiDataNotifier не установлен, центрирование карты пропущено");
}
}
}
@@ -761,6 +877,11 @@ public class AppController implements
stopAllListeners();
stopDatabaseCleanup();
// Очищаем Handler'ы для предотвращения утечек памяти
if (uiHandler != null) {
uiHandler.removeCallbacksAndMessages(null);
}
if (udpListener != null) {
udpListener.cleanup();
}
@@ -924,4 +1045,142 @@ public class AppController implements
dataMode != null ? dataMode : "не установлен"
);
}
// ===== Методы для работы с путем судна =====
/**
* Получает контроллер пути судна
*/
public VesselPathController getPathController() {
return pathController;
}
/**
* Получает информацию о пути судна
*/
public String getVesselPathInfo() {
if (pathController != null) {
return pathController.getPathInfo();
}
return "Контроллер пути не инициализирован";
}
/**
* Очищает путь судна
*/
public void clearVesselPath() {
if (pathController != null) {
pathController.clearPath();
Log.i(TAG, "Путь судна очищен");
}
}
/**
* Сохраняет путь судна
*/
public void saveVesselPath() {
if (pathController != null) {
Log.d(TAG, "Сохранение пути судна: " + pathController.getPathInfo());
}
}
/**
* Добавляет точку в путь AIS судна
*/
private void addAISVesselPathPoint(AISVessel vessel) {
if (vessel == null || vessel.getMmsi() == null) {
return;
}
// Проверяем валидность координат
if (!isValidCoordinates(vessel.getLatitude(), vessel.getLongitude())) {
Log.d(TAG, "addAISVesselPathPoint: AIS vessel " + vessel.getMmsi() +
" has invalid coordinates " + vessel.getLatitude() + "," + vessel.getLongitude() +
" - skipping path point");
return;
}
String mmsi = vessel.getMmsi();
// Получаем или создаем VesselPathController для этого AIS судна
VesselPathController aisPathController = aisPathControllers.get(mmsi);
if (aisPathController == null) {
// Ограничиваем количество трекеров для производительности
if (aisPathControllers.size() >= 20) {
Log.w(TAG, "Достигнуто максимальное количество AIS трекеров (20), пропускаем создание для " + mmsi);
return;
}
aisPathController = new VesselPathController(context, settingsManager, mmsi);
aisPathControllers.put(mmsi, aisPathController);
Log.d(TAG, "Создан VesselPathController для AIS судна " + mmsi + " (всего трекеров: " + aisPathControllers.size() + ")");
}
// Добавляем точку в путь
boolean pointAdded = aisPathController.addPathPoint(
vessel.getLongitude(),
vessel.getLatitude(),
(float) vessel.getSpeed()
);
if (pointAdded) {
Log.d(TAG, "Точка пути добавлена для AIS " + mmsi + ": " + aisPathController.getPathPointsCount() + " точек");
}
}
/**
* Проверяет валидность координат
* Игнорирует координаты 0,0 и 181,91 (невалидные значения AIS)
*/
private boolean isValidCoordinates(double latitude, double longitude) {
// Проверяем на нулевые координаты
if (latitude == 0.0 && longitude == 0.0) {
return false;
}
// Проверяем на невалидные координаты AIS (181, 91)
if (latitude == 91.0 && longitude == 181.0) {
return false;
}
// Проверяем на стандартные границы координат
if (latitude < -90.0 || latitude > 90.0) {
return false;
}
if (longitude < -180.0 || longitude > 180.0) {
return false;
}
return true;
}
/**
* Получает VesselPathController для AIS судна
*/
public VesselPathController getAISVesselPathController(String mmsi) {
return aisPathControllers.get(mmsi);
}
/**
* Очищает путь AIS судна
*/
public void clearAISVesselPath(String mmsi) {
VesselPathController aisPathController = aisPathControllers.get(mmsi);
if (aisPathController != null) {
aisPathController.clearPath();
Log.d(TAG, "Путь AIS судна " + mmsi + " очищен");
}
}
/**
* Очищает все пути AIS судов
*/
public void clearAllAISVesselPaths() {
for (VesselPathController controller : aisPathControllers.values()) {
controller.clearPath();
}
aisPathControllers.clear();
Log.d(TAG, "Все пути AIS судов очищены");
}
}
@@ -279,7 +279,7 @@ public class GPSLocationListener implements LocationListener {
this.pdop = pdop;
this.hdop = hdop;
this.vdop = vdop;
Log.d(TAG, "📊 DOP обновлен: PDOP=" + pdop + ", HDOP=" + hdop + ", VDOP=" + vdop);
// Убираем шумный лог DOP обновлений
}
/**
@@ -293,8 +293,7 @@ public class GPSLocationListener implements LocationListener {
// Устанавливаем только количество активных спутников
vessel.setActiveSatellites(activeSatellites);
Log.d(TAG, "Обновлен Vessel: активных спутников=" + activeSatellites +
" (общее количество из NMEA: " + vessel.getSatellites() + ")");
// Убираем шумный лог обновления Vessel
}
}
@@ -4,6 +4,7 @@ import android.content.Context;
import android.util.Log;
import com.grigowashere.aismap.maps.MapInterface;
import com.grigowashere.aismap.maps.YandexMapImpl;
import com.grigowashere.aismap.maps.MapLibreMapImpl;
import com.yandex.mapkit.mapview.MapView;
/**
@@ -18,6 +19,7 @@ public class MapController {
private Context context;
private MapInterface currentMapInterface;
private MapView mapView;
private org.maplibre.android.maps.MapView mapLibreView;
public MapController(Context context) {
this.context = context;
@@ -39,6 +41,41 @@ public class MapController {
return null;
}
}
/**
* Инициализирует MapLibre
*/
public MapInterface initializeMapLibre(org.maplibre.android.maps.MapView mapLibreView) {
try {
this.mapLibreView = mapLibreView;
Log.i(TAG, "Создаем интерфейс для MapLibre");
currentMapInterface = new MapLibreMapImpl(context, mapLibreView);
return currentMapInterface;
} catch (Exception e) {
Log.e(TAG, "Ошибка при создании интерфейса MapLibre: " + e.getMessage());
return null;
}
}
/**
* Устанавливает VesselPathController в текущий интерфейс карты
*/
public void setVesselPathController(VesselPathController pathController) {
if (currentMapInterface instanceof MapLibreMapImpl) {
((MapLibreMapImpl) currentMapInterface).setVesselPathController(pathController);
Log.i(TAG, "VesselPathController установлен в MapLibreMapImpl");
}
}
/**
* Устанавливает AppController в текущий интерфейс карты
*/
public void setAppController(AppController appController) {
if (currentMapInterface instanceof MapLibreMapImpl) {
((MapLibreMapImpl) currentMapInterface).setAppController(appController);
Log.i(TAG, "AppController установлен в MapLibreMapImpl");
}
}
/**
* Инициализирует Яндекс.Карты
@@ -81,9 +118,8 @@ public class MapController {
* Запускает карту
*/
public void startMap() {
if (mapView != null) {
mapView.onStart();
}
if (mapView != null) { mapView.onStart(); }
if (mapLibreView != null) { mapLibreView.onStart(); }
if (isYandexMapsInitialized) {
com.yandex.mapkit.MapKitFactory.getInstance().onStart();
@@ -94,9 +130,8 @@ public class MapController {
* Останавливает карту
*/
public void stopMap() {
if (mapView != null) {
mapView.onStop();
}
if (mapView != null) { mapView.onStop(); }
if (mapLibreView != null) { mapLibreView.onStop(); }
if (isYandexMapsInitialized) {
com.yandex.mapkit.MapKitFactory.getInstance().onStop();
@@ -125,9 +160,8 @@ public class MapController {
currentMapInterface.cleanup();
}
if (mapView != null) {
mapView.onStop();
}
if (mapView != null) { mapView.onStop(); }
if (mapLibreView != null) { mapLibreView.onStop(); }
if (isYandexMapsInitialized) {
com.yandex.mapkit.MapKitFactory.getInstance().onStop();
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,428 @@
package com.grigowashere.aismap.controllers;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.grigowashere.aismap.models.VesselPathPoint;
import com.grigowashere.aismap.utils.SettingsManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* Контроллер для управления путем судна
* Отвечает за запись, сохранение и восстановление точек пути
*/
public class VesselPathController {
private static final String TAG = "VesselPathController";
private static final String PREFS_NAME_PREFIX = "VesselPathData_";
private static final String KEY_PATH_POINTS = "path_points";
private static final String KEY_LAST_UPDATE = "last_update";
// Минимальное расстояние между точками (в метрах)
private static final double MIN_DISTANCE_METERS = 1.0; // Уменьшено с 10.0 до 1.0 метра
// Минимальное время между точками (в секундах)
private static final long MIN_TIME_SECONDS = 1; // Уменьшено с 5 до 1 секунды
// Максимальное количество точек для производительности
private static final int MAX_PATH_POINTS = 1000; // Ограничение для предотвращения зависаний
private Context context;
private SettingsManager settingsManager;
private SharedPreferences prefs;
private String vesselId; // Уникальный идентификатор судна
// Handler для UI операций
private Handler uiHandler;
// Список точек пути
private List<VesselPathPoint> pathPoints;
// Последняя добавленная точка
private VesselPathPoint lastPoint;
public VesselPathController(Context context, SettingsManager settingsManager) {
this(context, settingsManager, "own_vessel"); // По умолчанию для собственного судна
}
public VesselPathController(Context context, SettingsManager settingsManager, String vesselId) {
this.context = context;
this.settingsManager = settingsManager;
this.vesselId = vesselId;
this.prefs = context.getSharedPreferences(PREFS_NAME_PREFIX + vesselId, Context.MODE_PRIVATE);
this.pathPoints = new ArrayList<>();
this.uiHandler = new Handler(Looper.getMainLooper());
// Загружаем сохраненные точки в фоновом потоке
loadPathPointsAsync();
Log.i(TAG, "VesselPathController инициализирован для судна " + vesselId);
}
/**
* Добавляет новую точку пути
* @param longitude долгота
* @param latitude широта
* @param speed скорость в узлах
* @return true если точка была добавлена, false если пропущена
*/
public boolean addPathPoint(double longitude, double latitude, float speed) {
// Проверяем валидность координат
if (!isValidCoordinates(latitude, longitude)) {
Log.d(TAG, "addPathPoint: invalid coordinates " + latitude + "," + longitude + " - skipping");
return false;
}
VesselPathPoint newPoint = new VesselPathPoint(longitude, latitude, speed);
// Проверяем, нужно ли добавлять точку
if (shouldAddPoint(newPoint)) {
// Синхронизируем доступ к pathPoints для избежания гонки потоков
synchronized (pathPoints) {
pathPoints.add(newPoint);
lastPoint = newPoint;
// Ограничиваем количество точек
limitPathPoints();
}
// Сохраняем изменения
savePathPoints();
Log.d(TAG, "Добавлена точка пути: " + newPoint + ", всего точек: " + pathPoints.size());
return true;
}
return false;
}
/**
* Проверяет, нужно ли добавлять точку
*/
private boolean shouldAddPoint(VesselPathPoint newPoint) {
// Если это первая точка
if (lastPoint == null) {
return true;
}
// Проверяем расстояние
double distance = lastPoint.distanceTo(newPoint);
if (distance < MIN_DISTANCE_METERS) {
Log.d(TAG, "Точка пропущена: расстояние слишком мало (" + distance + "м)");
return false;
}
// Проверяем время
long timeDiff = lastPoint.timeDifferenceSeconds(newPoint);
if (timeDiff < MIN_TIME_SECONDS) {
Log.d(TAG, "Точка пропущена: время слишком мало (" + timeDiff + "с)");
return false;
}
return true;
}
/**
* Ограничивает количество точек пути
*/
private void limitPathPoints() {
int maxPoints = settingsManager.getPathMaxPoints();
Log.d(TAG, "limitPathPoints: текущих точек=" + pathPoints.size() + ", лимит=" + maxPoints);
if (pathPoints.size() > maxPoints) {
// Удаляем самые старые точки
int toRemove = pathPoints.size() - maxPoints;
for (int i = 0; i < toRemove; i++) {
pathPoints.remove(0);
}
Log.d(TAG, "Удалено " + toRemove + " старых точек пути, осталось: " + pathPoints.size());
}
}
/**
* Получает точки пути в формате JSONArray для MapLibre
*/
public JSONArray getPathCoordinates() {
JSONArray coords = new JSONArray();
try {
// Синхронизируем доступ к pathPoints для избежания гонки потоков
synchronized (pathPoints) {
for (VesselPathPoint point : pathPoints) {
JSONArray coord = new JSONArray();
coord.put(point.getLongitude());
coord.put(point.getLatitude());
coords.put(coord);
}
}
} catch (JSONException e) {
Log.e(TAG, "Ошибка создания координат пути", e);
}
return coords;
}
/**
* Получает точки пути в формате JSONArray для MapLibre с учетом скорости
* Возвращает массив координат с информацией о скорости для динамического пунктира
*/
public JSONArray getPathCoordinatesWithSpeed() {
JSONArray coords = new JSONArray();
try {
// Синхронизируем доступ к pathPoints для избежания гонки потоков
synchronized (pathPoints) {
// Убираем лишние логи
// Log.d(TAG, "getPathCoordinatesWithSpeed: обрабатываем " + pathPoints.size() + " точек");
for (VesselPathPoint point : pathPoints) {
JSONArray coord = new JSONArray();
coord.put(point.getLongitude());
coord.put(point.getLatitude());
coord.put(point.getSpeed()); // Добавляем скорость для динамического пунктира
coords.put(coord);
}
}
// Убираем лишние логи
// Log.d(TAG, "getPathCoordinatesWithSpeed: создано " + coords.length() + " координат");
} catch (JSONException e) {
Log.e(TAG, "Ошибка создания координат пути с скоростью", e);
}
return coords;
}
/**
* Вычисляет среднюю скорость на участке пути
*/
public float getAverageSpeed() {
if (pathPoints.size() < 2) {
return 0.0f;
}
float totalSpeed = 0.0f;
for (VesselPathPoint point : pathPoints) {
totalSpeed += point.getSpeed();
}
return totalSpeed / pathPoints.size();
}
/**
* Получает последнюю точку пути
*/
public VesselPathPoint getLastPoint() {
return lastPoint;
}
/**
* Получает количество точек пути
*/
public int getPathPointsCount() {
synchronized (pathPoints) {
return pathPoints.size();
}
}
/**
* Очищает все точки пути
*/
public void clearPath() {
Log.i(TAG, "clearPath() вызван");
synchronized (pathPoints) {
int pointsCount = pathPoints.size();
pathPoints.clear();
lastPoint = null;
Log.i(TAG, "Очищено " + pointsCount + " точек из памяти");
}
// Удаляем точки из SharedPreferences
prefs.edit()
.remove(KEY_PATH_POINTS)
.putLong(KEY_LAST_UPDATE, System.currentTimeMillis())
.apply();
Log.i(TAG, "Путь очищен из памяти и SharedPreferences");
}
/**
* Сохраняет точки пути в SharedPreferences
*/
private void savePathPoints() {
try {
JSONArray jsonArray = new JSONArray();
// Синхронизируем доступ к pathPoints для избежания гонки потоков
synchronized (pathPoints) {
for (VesselPathPoint point : pathPoints) {
JSONObject jsonPoint = new JSONObject();
jsonPoint.put("longitude", point.getLongitude());
jsonPoint.put("latitude", point.getLatitude());
jsonPoint.put("speed", point.getSpeed());
jsonPoint.put("timestamp", point.getTimestamp());
jsonArray.put(jsonPoint);
}
}
prefs.edit()
.putString(KEY_PATH_POINTS, jsonArray.toString())
.putLong(KEY_LAST_UPDATE, System.currentTimeMillis())
.apply();
Log.d(TAG, "Сохранено " + pathPoints.size() + " точек пути");
} catch (JSONException e) {
Log.e(TAG, "Ошибка сохранения точек пути", e);
}
}
/**
* Загружает точки пути из SharedPreferences в фоновом потоке
*/
private void loadPathPointsAsync() {
new Thread(() -> {
try {
String jsonString = prefs.getString(KEY_PATH_POINTS, null);
if (jsonString == null || jsonString.isEmpty()) {
Log.d(TAG, "Нет сохраненных точек пути");
return;
}
JSONArray jsonArray = new JSONArray(jsonString);
List<VesselPathPoint> loadedPoints = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonPoint = jsonArray.getJSONObject(i);
VesselPathPoint point = new VesselPathPoint(
jsonPoint.getDouble("longitude"),
jsonPoint.getDouble("latitude"),
(float) jsonPoint.getDouble("speed"),
jsonPoint.getLong("timestamp")
);
loadedPoints.add(point);
}
// Обновляем UI поток через существующий Handler
uiHandler.post(() -> {
synchronized (pathPoints) {
pathPoints.clear();
pathPoints.addAll(loadedPoints);
// Устанавливаем последнюю точку
if (!pathPoints.isEmpty()) {
lastPoint = pathPoints.get(pathPoints.size() - 1);
}
}
Log.d(TAG, "Загружено " + loadedPoints.size() + " точек пути для судна " + vesselId);
});
} catch (Exception e) {
Log.e(TAG, "Ошибка загрузки точек пути", e);
}
}).start();
}
/**
* Загружает точки пути из SharedPreferences (синхронно)
*/
private void loadPathPoints() {
try {
String jsonString = prefs.getString(KEY_PATH_POINTS, null);
if (jsonString == null || jsonString.isEmpty()) {
Log.d(TAG, "Нет сохраненных точек пути");
return;
}
JSONArray jsonArray = new JSONArray(jsonString);
pathPoints.clear();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonPoint = jsonArray.getJSONObject(i);
VesselPathPoint point = new VesselPathPoint(
jsonPoint.getDouble("longitude"),
jsonPoint.getDouble("latitude"),
(float) jsonPoint.getDouble("speed"),
jsonPoint.getLong("timestamp")
);
pathPoints.add(point);
}
// Устанавливаем последнюю точку
if (!pathPoints.isEmpty()) {
lastPoint = pathPoints.get(pathPoints.size() - 1);
}
Log.i(TAG, "Загружено " + pathPoints.size() + " точек пути");
} catch (JSONException e) {
Log.e(TAG, "Ошибка загрузки точек пути", e);
pathPoints.clear();
}
}
/**
* Получает информацию о пути для отладки
*/
public String getPathInfo() {
synchronized (pathPoints) {
if (pathPoints.isEmpty()) {
return "Путь пуст";
}
VesselPathPoint first = pathPoints.get(0);
VesselPathPoint last = pathPoints.get(pathPoints.size() - 1);
return String.format("Путь: %d точек, от %s до %s, средняя скорость: %.1f узлов",
pathPoints.size(),
first.toString(),
last.toString(),
getAverageSpeed());
}
}
/**
* Проверяет валидность координат
* Игнорирует координаты 0,0 и 181,91 (невалидные значения AIS)
*/
private boolean isValidCoordinates(double latitude, double longitude) {
// Проверяем на нулевые координаты
if (latitude == 0.0 && longitude == 0.0) {
return false;
}
// Проверяем на невалидные координаты AIS (181, 91)
if (latitude == 91.0 && longitude == 181.0) {
return false;
}
// Проверяем на стандартные границы координат
if (latitude < -90.0 || latitude > 90.0) {
return false;
}
if (longitude < -180.0 || longitude > 180.0) {
return false;
}
return true;
}
/**
* Очистка ресурсов
*/
public void cleanup() {
if (uiHandler != null) {
uiHandler.removeCallbacksAndMessages(null);
uiHandler = null;
}
Log.d(TAG, "VesselPathController очищен для судна " + vesselId);
}
}
@@ -53,6 +53,22 @@ public class Repository {
public VesselEntity getLatestOwnVesselSync() {
return vesselDao.getLatest();
}
public void getLatestOwnVesselAsync(RepositoryCallback<VesselEntity> callback) {
ioExecutor.execute(() -> {
try {
VesselEntity entity = vesselDao.getLatest();
callback.onComplete(entity);
} catch (Exception e) {
callback.onError(e);
}
});
}
public interface RepositoryCallback<T> {
void onComplete(T result);
void onError(Exception e);
}
}
@@ -5,12 +5,15 @@ import android.graphics.Color;
import com.grigowashere.aismap.models.Vessel;
import com.grigowashere.aismap.models.AISVessel;
import com.grigowashere.aismap.view.CursorOverlay;
import com.grigowashere.aismap.R;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.layer.Layers;
import org.mapsforge.map.layer.overlay.Marker;
import org.mapsforge.map.model.Model;
import org.mapsforge.core.graphics.Bitmap;
import android.view.ViewGroup;
import java.util.HashMap;
import java.util.Map;
@@ -27,17 +30,30 @@ public class MapForgeImpl implements MapInterface {
private Map<String, Marker> aisMarkers;
private Marker ownVesselMarker;
private CursorOverlay cursorOverlay;
private Vessel ownVessel;
public MapForgeImpl(Context context, MapView mapView) {
this.context = context;
this.mapView = mapView;
this.aisMarkers = new HashMap<>();
this.layers = mapView.getLayerManager().getLayers();
this.cursorOverlay = new CursorOverlay(context);
// Добавляем overlay курсора в MapView
if (mapView instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) mapView;
// Проверяем, не добавлен ли уже курсор
if (parent.findViewById(R.id.cursor_cross) == null) {
parent.addView(cursorOverlay.getView());
}
}
}
@Override
public void initialize() {
// MapForge уже инициализирован
setupMapMovementListener();
}
@Override
@@ -53,6 +69,9 @@ public class MapForgeImpl implements MapInterface {
layers.remove(ownVesselMarker);
}
this.ownVessel = vessel;
cursorOverlay.setOwnVessel(vessel);
LatLong position = new LatLong(vessel.getLatitude(), vessel.getLongitude());
org.mapsforge.core.graphics.Bitmap icon = createMapForgeIcon(Color.BLUE, vessel.getCourse());
@@ -71,6 +90,9 @@ public class MapForgeImpl implements MapInterface {
org.mapsforge.core.graphics.Bitmap icon = createMapForgeIcon(Color.BLUE, vessel.getCourse());
ownVesselMarker.setBitmap(icon);
}
this.ownVessel = vessel;
cursorOverlay.setOwnVessel(vessel);
}
@Override
@@ -148,6 +170,13 @@ public class MapForgeImpl implements MapInterface {
this.markerClickListener = listener;
}
@Override
public void clearVesselPath() {
// MapForge не поддерживает трекинг пути в данной реализации
// Метод добавлен для совместимости с интерфейсом
// В будущем можно добавить поддержку трекинга пути для MapForge
}
private org.mapsforge.core.graphics.Bitmap createMapForgeIcon(int color, double course) {
// Создаем простую иконку для MapForge
// В реальном приложении нужно конвертировать Android Bitmap в MapForge Bitmap
@@ -155,6 +184,65 @@ public class MapForgeImpl implements MapInterface {
return null;
}
@Override
public void showCursor() {
if (cursorOverlay != null) {
// cursorOverlay.showCoordinates();
}
}
@Override
public void hideCursor() {
if (cursorOverlay != null) {
cursorOverlay.hideCursor();
}
}
@Override
public void updateCursorCoordinates(double latitude, double longitude) {
if (cursorOverlay != null) {
cursorOverlay.updateCursorCoordinates(latitude, longitude);
}
}
@Override
public void updateCursorFromMapCenter() {
if (cursorOverlay != null && mapView != null) {
// Получаем координаты центра карты
LatLong center = mapView.getModel().mapViewPosition.getCenter();
cursorOverlay.updateCursorCoordinates(center.latitude, center.longitude);
}
}
/**
* Настраивает слушатель движения карты для обновления курсора
*/
private void setupMapMovementListener() {
if (mapView != null) {
// mapView.getModel().mapViewPosition.addObserver(new org.mapsforge.map.model.Observer() {
// @Override
// public void onChange() {
// // Обновляем координаты курсора при движении карты
// updateCursorFromMapCenter();
// }
// });
}
}
@Override
public void setAisVesselInfo(com.grigowashere.aismap.models.AISVessel vessel) {
if (cursorOverlay != null) {
cursorOverlay.setAisVesselInfo(vessel);
}
}
@Override
public void clearAisVesselInfo() {
if (cursorOverlay != null) {
cursorOverlay.clearAisVesselInfo();
}
}
public MapView getMapView() {
return mapView;
}
@@ -79,6 +79,41 @@ public interface MapInterface {
*/
void setMarkerClickListener(MarkerClickListener listener);
/**
* Очистка трекера пути собственного судна
*/
void clearVesselPath();
/**
* Показать курсор на карте
*/
void showCursor();
/**
* Скрыть курсор на карте
*/
void hideCursor();
/**
* Обновить координаты курсора (центра экрана)
*/
void updateCursorCoordinates(double latitude, double longitude);
/**
* Обновить координаты курсора автоматически при движении карты
*/
void updateCursorFromMapCenter();
/**
* Установить информацию об AIS судне под курсором
*/
void setAisVesselInfo(com.grigowashere.aismap.models.AISVessel vessel);
/**
* Очистить информацию об AIS судне
*/
void clearAisVesselInfo();
/**
* Интерфейс для обработки кликов по меткам
*/
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,7 @@
package com.grigowashere.aismap.maps;
import android.graphics.Color;
import android.util.Log;
import com.yandex.mapkit.geometry.Point;
import com.yandex.mapkit.map.MapObjectCollection;
import com.yandex.mapkit.map.PolylineMapObject;
@@ -16,6 +17,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
*/
public class VesselPathTracker {
private static final String TAG = "VesselPathTracker";
private static final int MAX_PATH_POINTS = 100; // Максимальное количество точек в пути
private static final long MIN_TIME_BETWEEN_POINTS = 1000; // Минимальное время между точками (1 секунда)
private static final double MIN_DISTANCE_BETWEEN_POINTS = 10.0; // Минимальное расстояние между точками (10 метров)
@@ -58,6 +60,7 @@ public class VesselPathTracker {
this.mapObjects = mapObjects;
this.pathHistory = new ConcurrentLinkedQueue<>();
this.lastUpdateTime = 0;
Log.d(TAG, "Created VesselPathTracker for vessel: " + vesselId + ", mapObjects: " + (mapObjects != null ? "not null" : "null"));
}
/**
@@ -65,12 +68,17 @@ public class VesselPathTracker {
*/
public void updatePosition(double latitude, double longitude, double speed, double course) {
if (!isEnabled) {
Log.d(TAG, "VesselPathTracker disabled for vessel: " + vesselId);
return;
}
long currentTime = System.currentTimeMillis();
Point newPosition = new Point(latitude, longitude);
Log.d(TAG, "updatePosition called for vessel: " + vesselId +
", lat: " + latitude + ", lon: " + longitude +
", speed: " + speed + ", course: " + course);
// Проверяем, нужно ли добавить новую точку
if (shouldAddPoint(newPosition, currentTime)) {
PathPoint newPoint = new PathPoint(newPosition, currentTime, speed, course);
@@ -84,8 +92,14 @@ public class VesselPathTracker {
lastPosition = newPosition;
lastUpdateTime = currentTime;
Log.d(TAG, "Added new point to path for vessel: " + vesselId +
", total points: " + pathHistory.size());
// Обновляем отображение пути
updatePathDisplay();
} else {
Log.d(TAG, "Point not added for vessel: " + vesselId +
" (time or distance filter)");
}
}
@@ -113,10 +127,14 @@ public class VesselPathTracker {
* Обновляет отображение пути на карте
*/
private void updatePathDisplay() {
Log.d(TAG, "updatePathDisplay called for vessel: " + vesselId);
if (pathHistory.isEmpty()) {
Log.d(TAG, "Path history is empty for vessel: " + vesselId);
return;
}
if (mapObjects == null) {
Log.d(TAG, "MapObjects is null for vessel: " + vesselId);
return;
}
@@ -126,17 +144,22 @@ public class VesselPathTracker {
pathPoints.add(point.position);
}
Log.d(TAG, "Creating path line with " + pathPoints.size() + " points for vessel: " + vesselId);
// Удаляем старые линии
try {
if (pathLine != null) {
Log.d(TAG, "Removing old path line for vessel: " + vesselId);
mapObjects.remove(pathLine);
pathLine = null;
}
if (predictionLine != null) {
Log.d(TAG, "Removing old prediction line for vessel: " + vesselId);
mapObjects.remove(predictionLine);
predictionLine = null;
}
} catch (RuntimeException ignored) {
} catch (RuntimeException e) {
Log.e(TAG, "Error removing old lines for vessel: " + vesselId, e);
// Коллекция могла быть инвалидирована (weak_ptr expired). Прекращаем обновления.
isEnabled = false;
return;
@@ -145,15 +168,25 @@ public class VesselPathTracker {
// Создаем линию пройденного пути
if (pathPoints.size() > 1) {
try {
Log.d(TAG, "Adding new path line for vessel: " + vesselId);
pathLine = mapObjects.addPolyline(new com.yandex.mapkit.geometry.Polyline(pathPoints));
if (pathLine != null) {
pathLine.setStrokeColor(pathColor);
pathLine.setStrokeWidth(pathWidth);
Log.d(TAG, "Path line created successfully for vessel: " + vesselId +
", color: " + Integer.toHexString(pathColor) +
", width: " + pathWidth);
} else {
Log.e(TAG, "Failed to create path line for vessel: " + vesselId);
}
} catch (RuntimeException ignored) {
} catch (RuntimeException e) {
Log.e(TAG, "Error creating path line for vessel: " + vesselId, e);
isEnabled = false;
return;
}
} else {
Log.d(TAG, "Not enough points for path line for vessel: " + vesselId +
" (need at least 2, have " + pathPoints.size() + ")");
}
// Создаем линию прогнозируемого движения
@@ -164,10 +197,14 @@ public class VesselPathTracker {
* Создает линию прогнозируемого движения
*/
private void createPredictionLine() {
Log.d(TAG, "createPredictionLine called for vessel: " + vesselId);
if (pathHistory.isEmpty()) {
Log.d(TAG, "Path history is empty for prediction line for vessel: " + vesselId);
return;
}
if (mapObjects == null) {
Log.d(TAG, "MapObjects is null for prediction line for vessel: " + vesselId);
return;
}
@@ -178,6 +215,9 @@ public class VesselPathTracker {
}
if (lastPoint == null || lastPoint.speed <= 0) {
Log.d(TAG, "Cannot create prediction line for vessel: " + vesselId +
" (lastPoint: " + (lastPoint != null ? "not null" : "null") +
", speed: " + (lastPoint != null ? lastPoint.speed : "N/A") + ")");
return;
}
@@ -185,6 +225,11 @@ public class VesselPathTracker {
double predictionTimeMinutes = 1.0; // 1 минута
double predictionDistance = lastPoint.speed * predictionTimeMinutes * 60.0; // расстояние в метрах
Log.d(TAG, "Creating prediction line for vessel: " + vesselId +
", speed: " + lastPoint.speed +
", course: " + lastPoint.course +
", prediction distance: " + predictionDistance + "m");
// Конвертируем курс в радианы
double courseRad = Math.toRadians(lastPoint.course);
@@ -207,13 +252,19 @@ public class VesselPathTracker {
predictionPoints.add(predictionPoint);
try {
Log.d(TAG, "Adding prediction line for vessel: " + vesselId);
predictionLine = mapObjects.addPolyline(new com.yandex.mapkit.geometry.Polyline(predictionPoints));
if (predictionLine != null) {
predictionLine.setStrokeColor(predictionColor);
predictionLine.setStrokeWidth(predictionWidth);
// Сплошная линия для прогноза (по умолчанию)
Log.d(TAG, "Prediction line created successfully for vessel: " + vesselId +
", color: " + Integer.toHexString(predictionColor) +
", width: " + predictionWidth);
} else {
Log.e(TAG, "Failed to create prediction line for vessel: " + vesselId);
}
} catch (RuntimeException ignored) {
} catch (RuntimeException e) {
Log.e(TAG, "Error creating prediction line for vessel: " + vesselId, e);
isEnabled = false;
}
}
@@ -10,7 +10,10 @@ import android.view.View;
import com.grigowashere.aismap.models.Vessel;
import com.grigowashere.aismap.models.AISVessel;
import com.grigowashere.aismap.view.CursorOverlay;
import com.grigowashere.aismap.R;
import com.yandex.mapkit.Animation;
import android.view.ViewGroup;
import com.yandex.mapkit.geometry.Point;
import com.yandex.mapkit.map.CameraPosition;
import com.yandex.mapkit.map.MapObjectCollection;
@@ -38,9 +41,23 @@ public class YandexMapImpl implements MapInterface {
private com.yandex.mapkit.map.InputListener inputListener;
private float lastMapAzimuth = 0.0f;
// Курсор overlay
private CursorOverlay cursorOverlay;
private Vessel ownVessel;
public YandexMapImpl(Context context, MapView mapView) {
this.context = context;
this.mapView = mapView;
this.cursorOverlay = new CursorOverlay(context);
// Добавляем overlay курсора в MapView
if (mapView instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) mapView;
// Проверяем, не добавлен ли уже курсор
if (parent.findViewById(R.id.cursor_cross) == null) {
parent.addView(cursorOverlay.getView());
}
}
// Получение коллекции объектов карты
try {
@@ -59,6 +76,9 @@ public class YandexMapImpl implements MapInterface {
// Инициализируем слушатель поворота карты
setupCameraListener();
// Инициализируем слушатель движения карты
setupMapMovementListener();
// Инициализируем менеджер маркеров
if (markerManager != null) {
markerManager.initialize();
@@ -88,6 +108,10 @@ public class YandexMapImpl implements MapInterface {
@Override
public void addOwnVesselMarker(Vessel vessel) {
this.ownVessel = vessel;
if (cursorOverlay != null) {
cursorOverlay.setOwnVessel(vessel);
}
if (markerManager != null) {
markerManager.updateOwnVesselMarker(vessel);
}
@@ -95,6 +119,10 @@ public class YandexMapImpl implements MapInterface {
@Override
public void updateOwnVesselPosition(Vessel vessel) {
this.ownVessel = vessel;
if (cursorOverlay != null) {
cursorOverlay.setOwnVessel(vessel);
}
if (markerManager != null) {
markerManager.updateOwnVesselMarker(vessel);
}
@@ -255,6 +283,21 @@ public class YandexMapImpl implements MapInterface {
}
}
/**
* Очищает трекер пути собственного судна
*/
@Override
public void clearVesselPath() {
if (markerManager != null) {
markerManager.clearVesselPath("own_vessel");
}
// Также очищаем VesselPathController если он используется
// (для MapLibre это делается в MapLibreMapImpl, для Yandex - здесь)
// В YandexMapImpl VesselPathController не используется напрямую,
// но если в будущем будет использоваться, нужно добавить очистку
}
/**
* Очищает все пути движения
*/
@@ -359,4 +402,63 @@ public class YandexMapImpl implements MapInterface {
}
}
@Override
public void showCursor() {
if (cursorOverlay != null) {
cursorOverlay.showCursor();
}
}
@Override
public void hideCursor() {
if (cursorOverlay != null) {
cursorOverlay.hideCursor();
}
}
@Override
public void updateCursorCoordinates(double latitude, double longitude) {
if (cursorOverlay != null) {
cursorOverlay.updateCursorCoordinates(latitude, longitude);
}
}
@Override
public void updateCursorFromMapCenter() {
if (cursorOverlay != null && mapView != null) {
// Получаем координаты центра карты
com.yandex.mapkit.geometry.Point center = mapView.getMap().getCameraPosition().getTarget();
cursorOverlay.updateCursorCoordinates(center.getLatitude(), center.getLongitude());
}
}
@Override
public void setAisVesselInfo(com.grigowashere.aismap.models.AISVessel vessel) {
if (cursorOverlay != null) {
cursorOverlay.setAisVesselInfo(vessel);
}
}
@Override
public void clearAisVesselInfo() {
if (cursorOverlay != null) {
cursorOverlay.clearAisVesselInfo();
}
}
/**
* Настраивает слушатель движения карты для обновления курсора
*/
private void setupMapMovementListener() {
if (mapView != null) {
mapView.getMap().addCameraListener(new com.yandex.mapkit.map.CameraListener() {
@Override
public void onCameraPositionChanged(com.yandex.mapkit.map.Map map, com.yandex.mapkit.map.CameraPosition cameraPosition, com.yandex.mapkit.map.CameraUpdateReason cameraUpdateReason, boolean finished) {
// Обновляем координаты курсора при движении карты
updateCursorFromMapCenter();
}
});
}
}
}
@@ -0,0 +1,128 @@
package com.grigowashere.aismap.models;
import java.io.Serializable;
/**
* Модель точки пути судна
* Содержит координаты, скорость и время прохождения
*/
public class VesselPathPoint implements Serializable {
private static final long serialVersionUID = 1L;
private double longitude;
private double latitude;
private float speed; // скорость в узлах
private long timestamp; // время в миллисекундах
public VesselPathPoint() {
this.timestamp = System.currentTimeMillis();
}
public VesselPathPoint(double longitude, double latitude, float speed) {
this.longitude = longitude;
this.latitude = latitude;
this.speed = speed;
this.timestamp = System.currentTimeMillis();
}
public VesselPathPoint(double longitude, double latitude, float speed, long timestamp) {
this.longitude = longitude;
this.latitude = latitude;
this.speed = speed;
this.timestamp = timestamp;
}
// Геттеры и сеттеры
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public float getSpeed() {
return speed;
}
public void setSpeed(float speed) {
this.speed = speed;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
/**
* Вычисляет расстояние до другой точки в метрах
*/
public double distanceTo(VesselPathPoint other) {
if (other == null) return 0;
final int R = 6371000; // радиус Земли в метрах
double lat1Rad = Math.toRadians(this.latitude);
double lat2Rad = Math.toRadians(other.latitude);
double deltaLatRad = Math.toRadians(other.latitude - this.latitude);
double deltaLonRad = Math.toRadians(other.longitude - this.longitude);
double a = Math.sin(deltaLatRad / 2) * Math.sin(deltaLatRad / 2) +
Math.cos(lat1Rad) * Math.cos(lat2Rad) *
Math.sin(deltaLonRad / 2) * Math.sin(deltaLonRad / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c;
}
/**
* Вычисляет время между точками в секундах
*/
public long timeDifferenceSeconds(VesselPathPoint other) {
if (other == null) return 0;
return Math.abs(this.timestamp - other.timestamp) / 1000;
}
@Override
public String toString() {
return String.format("VesselPathPoint{lon=%.6f, lat=%.6f, speed=%.1f, time=%d}",
longitude, latitude, speed, timestamp);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
VesselPathPoint that = (VesselPathPoint) obj;
return Double.compare(that.longitude, longitude) == 0 &&
Double.compare(that.latitude, latitude) == 0 &&
Float.compare(that.speed, speed) == 0 &&
timestamp == that.timestamp;
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(longitude);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(latitude);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (speed != 0.0f ? Float.floatToIntBits(speed) : 0);
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
return result;
}
}
@@ -26,6 +26,9 @@ public class CompassSensor implements SensorEventListener {
private CompassListener compassListener;
private boolean isListening = false;
// Диагностика
private long lastLogTime = 0;
// Скользящий фильтр для сглаживания значений
private static final int FILTER_SIZE = 60;
private float[] azimuthBuffer = new float[FILTER_SIZE];
@@ -85,6 +88,13 @@ public class CompassSensor implements SensorEventListener {
@Override
public void onSensorChanged(SensorEvent event) {
// Диагностика: логируем каждые 10 секунд
long now = System.currentTimeMillis();
if (now - lastLogTime > 10000) {
Log.d(TAG, "🧭 CompassSensor: onSensorChanged работает (тип: " + event.sensor.getType() + ")");
lastLogTime = now;
}
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
System.arraycopy(event.values, 0, accelerometerReading, 0, accelerometerReading.length);
} else if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
@@ -121,6 +131,12 @@ public class CompassSensor implements SensorEventListener {
// Уведомляем слушателя
if (compassListener != null) {
// Диагностика: логируем каждые 10 секунд
long now = System.currentTimeMillis();
if (now - lastLogTime > 10000) {
Log.d(TAG, "🧭 CompassSensor: onCompassChanged вызывается, azimuth=" + filteredAzimuth);
lastLogTime = now;
}
compassListener.onCompassChanged(filteredAzimuth);
}
}
@@ -20,22 +20,49 @@ public class AISForegroundService extends Service {
public static final String CHANNEL_ID = "aismap_foreground";
private static final int NOTIFICATION_ID = 1001;
// Константы для действий
public static final String ACTION_STOP_SERVICE = "com.grigowashere.aismap.STOP_SERVICE";
@Override
public void onCreate() {
super.onCreate();
createNotificationChannel();
startForeground(NOTIFICATION_ID, buildNotification("Работа в фоне: обновление AIS/GPS"));
android.util.Log.i("AISForegroundService", "onCreate() вызван");
try {
createNotificationChannel();
Notification notification = buildNotification("Работа в фоне: обновление AIS/GPS");
android.util.Log.i("AISForegroundService", "Уведомление создано: " + notification);
startForeground(NOTIFICATION_ID, notification);
android.util.Log.i("AISForegroundService", "Сервис запущен в форграунд режиме");
} catch (Exception e) {
android.util.Log.e("AISForegroundService", "Ошибка при запуске сервиса: " + e.getMessage(), e);
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && ACTION_STOP_SERVICE.equals(intent.getAction())) {
// Останавливаем сервис
stopForeground(true);
stopSelf();
return START_NOT_STICKY;
}
// Здесь в дальнейшем запустим прием NMEA/UDP и GPS слушателей
return START_STICKY;
}
@Override
public void onDestroy() {
// Останавливаем форграунд режим
stopForeground(true);
// Здесь можно добавить очистку ресурсов, если они есть
// Например, остановка GPS слушателей, UDP соединений и т.д.
android.util.Log.i("AISForegroundService", "Сервис остановлен");
super.onDestroy();
}
@@ -46,28 +73,47 @@ public class AISForegroundService extends Service {
}
private void createNotificationChannel() {
android.util.Log.i("AISForegroundService", "Создание канала уведомлений...");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID,
"AISMap Background",
NotificationManager.IMPORTANCE_LOW
NotificationManager.IMPORTANCE_DEFAULT
);
channel.setDescription("Фоновые обновления AIS и GPS");
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (nm != null) nm.createNotificationChannel(channel);
if (nm != null) {
nm.createNotificationChannel(channel);
android.util.Log.i("AISForegroundService", "Канал уведомлений создан: " + CHANNEL_ID);
} else {
android.util.Log.e("AISForegroundService", "NotificationManager равен null!");
}
} else {
android.util.Log.i("AISForegroundService", "Android версия < O, канал не нужен");
}
}
private Notification buildNotification(String content) {
android.util.Log.i("AISForegroundService", "Создание уведомления с текстом: " + content);
Intent notificationIntent = new Intent(this, MainActivity.class);
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT : 0;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, flags);
// Создаем действие для остановки сервиса
Intent stopIntent = new Intent(this, AISForegroundService.class);
stopIntent.setAction(ACTION_STOP_SERVICE);
PendingIntent stopPendingIntent = PendingIntent.getService(this, 0, stopIntent, flags);
android.util.Log.i("AISForegroundService", "Создание уведомления с кнопкой остановки");
return new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("AISMap")
.setContentText(content)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
.setOngoing(true)
.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Остановить", stopPendingIntent)
.build();
}
}
@@ -0,0 +1,55 @@
package com.grigowashere.aismap.ui;
import com.grigowashere.aismap.models.Vessel;
import com.grigowashere.aismap.models.AISVessel;
/**
* Интерфейс для уведомлений UI о изменениях данных
* Контроллеры используют этот интерфейс для информирования UI о изменениях
* без знания деталей UI реализации
*/
public interface UIDataChangeNotifier {
/**
* Уведомление об изменении позиции собственного судна
* @param vessel обновленные данные судна
*/
void onVesselPositionChanged(Vessel vessel);
/**
* Уведомление об изменении качества GPS данных
* @param vessel данные судна с обновленными GPS метаданными
*/
void onGPSQualityChanged(Vessel vessel);
/**
* Уведомление о новой AIS судне или обновлении существующего
* @param vessel данные AIS судна
*/
void onAISVesselChanged(AISVessel vessel);
/**
* Уведомление об удалении AIS судна
* @param mmsi идентификатор удаляемого судна
*/
void onAISVesselRemoved(String mmsi);
/**
* Уведомление об изменении пути судна
* @param mmsi идентификатор судна (null для собственного судна)
*/
void onVesselPathChanged(String mmsi);
/**
* Уведомление о центрировании карты
* @param latitude широта
* @param longitude долгота
*/
void onRequestCenterMap(double latitude, double longitude);
/**
* Уведомление об обновлении компаса
* @param azimuth значение азимута
*/
void onCompassUpdate(float azimuth);
}
@@ -0,0 +1,278 @@
package com.grigowashere.aismap.ui;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.grigowashere.aismap.maps.MapInterface;
import com.grigowashere.aismap.models.Vessel;
import com.grigowashere.aismap.models.AISVessel;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
/**
* Координатор UI отрисовки
* Единая точка всех операций с картой и UI
* Обеспечивает throttling и батчинг операций
*/
public class UIRenderingCoordinator implements UIDataChangeNotifier {
private static final String TAG = "UIRenderingCoordinator";
// Throttling интервалы
public static final long VESSEL_UPDATE_THROTTLE = 500; // 500мс для позиции судна
public static final long AIS_UPDATE_THROTTLE = 1000; // 1сек для AIS данных
public static final long PATH_UPDATE_THROTTLE = 2000; // 2сек для путей
private MapInterface mapInterface;
private Handler uiHandler;
// Pending операции для батчинга
private Vessel pendingVesselUpdate;
private final Map<String, AISVessel> pendingAISUpdates = new HashMap<>();
private final Set<String> pendingAISRemovals = new HashSet<>();
// Throttling Runnable's
private Runnable vesselUpdateRunnable;
private Runnable aisUpdateRunnable;
private Runnable pathUpdateRunnable;
// Флаги для предотвращения множественных запланированных операций
private boolean vesselUpdatePending = false;
private boolean aisUpdatePending = false;
private boolean pathUpdatePending = false;
public UIRenderingCoordinator(MapInterface mapInterface) {
this.mapInterface = mapInterface;
this.uiHandler = new Handler(Looper.getMainLooper());
setupThrottling();
Log.i(TAG, "UIRenderingCoordinator инициализирован");
}
/**
* Настройка throttling механизмов
*/
private void setupThrottling() {
vesselUpdateRunnable = () -> {
vesselUpdatePending = false;
executeVesselUpdate();
};
aisUpdateRunnable = () -> {
aisUpdatePending = false;
executeAISUpdates();
};
pathUpdateRunnable = () -> {
pathUpdatePending = false;
executePathUpdates();
};
}
/**
* Запрос обновления позиции собственного судна
*/
public void requestVesselUpdate(Vessel vessel) {
if (vessel == null) return;
pendingVesselUpdate = vessel;
if (!vesselUpdatePending) {
vesselUpdatePending = true;
uiHandler.removeCallbacks(vesselUpdateRunnable);
uiHandler.postDelayed(vesselUpdateRunnable, VESSEL_UPDATE_THROTTLE);
Log.d(TAG, "Vessel update запланирован на " + VESSEL_UPDATE_THROTTLE + "мс");
}
}
/**
* Запрос обновления AIS судна
*/
public void requestAISUpdate(AISVessel vessel) {
if (vessel == null || vessel.getMmsi() == null) return;
pendingAISUpdates.put(vessel.getMmsi(), vessel);
if (!aisUpdatePending) {
aisUpdatePending = true;
uiHandler.removeCallbacks(aisUpdateRunnable);
uiHandler.postDelayed(aisUpdateRunnable, AIS_UPDATE_THROTTLE);
Log.d(TAG, "AIS update запланирован на " + AIS_UPDATE_THROTTLE + "мс");
}
}
/**
* Запрос удаления AIS судна
*/
public void requestAISRemoval(String mmsi) {
if (mmsi == null) return;
pendingAISRemovals.add(mmsi);
pendingAISUpdates.remove(mmsi); // Убираем из обновлений
if (!aisUpdatePending) {
aisUpdatePending = true;
uiHandler.removeCallbacks(aisUpdateRunnable);
uiHandler.postDelayed(aisUpdateRunnable, AIS_UPDATE_THROTTLE);
Log.d(TAG, "AIS removal запланирован на " + AIS_UPDATE_THROTTLE + "мс");
}
}
/**
* Выполнение обновления позиции судна
*/
private void executeVesselUpdate() {
if (mapInterface == null || pendingVesselUpdate == null) return;
try {
Log.d(TAG, "Выполняем vessel update: " + pendingVesselUpdate.getLatitude() + "," + pendingVesselUpdate.getLongitude());
mapInterface.updateOwnVesselPosition(pendingVesselUpdate);
Log.d(TAG, "Vessel update выполнен успешно");
} catch (Exception e) {
Log.e(TAG, "Ошибка vessel update: " + e.getMessage(), e);
}
pendingVesselUpdate = null;
}
/**
* Выполнение обновлений AIS судов
*/
private void executeAISUpdates() {
if (mapInterface == null) return;
try {
// Удаляем старые суда
for (String mmsi : pendingAISRemovals) {
Log.d(TAG, "Удаляем AIS судно: " + mmsi);
mapInterface.removeAISVesselMarker(mmsi);
}
// Обновляем или добавляем суда (различать не будем - MapInterface сам решит)
for (AISVessel vessel : pendingAISUpdates.values()) {
Log.d(TAG, "Обновляем/добавляем AIS судно: " + vessel.getMmsi());
mapInterface.updateAISVesselPosition(vessel);
}
Log.d(TAG, "AIS updates выполнены: удалено=" + pendingAISRemovals.size() +
", обновлено=" + pendingAISUpdates.size());
} catch (Exception e) {
Log.e(TAG, "Ошибка AIS updates: " + e.getMessage(), e);
}
// Очищаем pending операции
pendingAISUpdates.clear();
pendingAISRemovals.clear();
}
/**
* Выполнение обновлений путей (заглушка для будущего)
*/
private void executePathUpdates() {
if (mapInterface == null) return;
try {
// TODO: Реализовать батчинговое обновление путей
Log.d(TAG, "Path updates выполнены (заглушка)");
} catch (Exception e) {
Log.e(TAG, "Ошибка path updates: " + e.getMessage(), e);
}
}
/**
* Принудительное выполнение всех pending операций
*/
public void flushPendingOperations() {
Log.i(TAG, "Принудительное выполнение всех pending операций");
if (uiHandler != null) {
uiHandler.removeCallbacks(vesselUpdateRunnable);
uiHandler.removeCallbacks(aisUpdateRunnable);
uiHandler.removeCallbacks(pathUpdateRunnable);
}
vesselUpdatePending = false;
aisUpdatePending = false;
pathUpdatePending = false;
executeVesselUpdate();
executeAISUpdates();
executePathUpdates();
Log.i(TAG, "Все pending операции выполнены");
}
/**
* Очистка ресурсов
*/
public void cleanup() {
Log.i(TAG, "Очистка UIRenderingCoordinator");
if (uiHandler != null) {
uiHandler.removeCallbacksAndMessages(null);
}
flushPendingOperations();
mapInterface = null;
Log.i(TAG, "UIRenderingCoordinator очищен");
}
// ========== Реализация UIDataChangeNotifier ==========
@Override
public void onVesselPositionChanged(Vessel vessel) {
requestVesselUpdate(vessel);
}
@Override
public void onGPSQualityChanged(Vessel vessel) {
// GPS качество влияет на отображение точности, но не требует urgent update
requestVesselUpdate(vessel);
}
@Override
public void onAISVesselChanged(AISVessel vessel) {
requestAISUpdate(vessel);
}
@Override
public void onAISVesselRemoved(String mmsi) {
requestAISRemoval(mmsi);
}
@Override
public void onVesselPathChanged(String mmsi) {
// Path изменения менее критичны, используем больше throttling
if (!pathUpdatePending) {
pathUpdatePending = true;
uiHandler.removeCallbacks(pathUpdateRunnable);
uiHandler.postDelayed(pathUpdateRunnable, PATH_UPDATE_THROTTLE);
Log.d(TAG, "Path update запланирован на " + PATH_UPDATE_THROTTLE + "мс");
}
}
@Override
public void onRequestCenterMap(double latitude, double longitude) {
// Центрирование карты должно происходить немедленно
uiHandler.post(() -> {
if (mapInterface != null) {
mapInterface.centerOnPosition(latitude, longitude);
Log.d(TAG, "Карта отцентрирована на " + latitude + "," + longitude);
}
});
}
@Override
public void onCompassUpdate(float azimuth) {
// Компас не относится к карте, передаем в MainActivity через callback
Log.d(TAG, "Compass update: " + azimuth + "° - требует специальной обработки в MainActivity");
}
}
@@ -34,7 +34,8 @@ public class LogSender {
String url = BASE_URL + "?nmea=" + encodedMessage + "&color=blue";
sendGetRequest(url);
Log.d(TAG, "NMEA лог отправлен: " + nmeaMessage);
// Убираем лишние логи
// Log.d(TAG, "NMEA лог отправлен: " + nmeaMessage);
} catch (Exception e) {
Log.e(TAG, "Ошибка отправки NMEA лога: " + e.getMessage(), e);
}
@@ -67,7 +68,8 @@ public class LogSender {
String url = BASE_URL + "?ships=" + encodedMessage + "&color=" + encodedColor;
sendGetRequest(url);
Log.d(TAG, "Ship update лог отправлен: " + message + " ( " + ", цвет: " + vesselColor + ")");
// Убираем лишние логи
// Log.d(TAG, "Ship update лог отправлен: " + message + " ( " + ", цвет: " + vesselColor + ")");
} catch (Exception e) {
Log.e(TAG, "Ошибка отправки ship update лога: " + e.getMessage(), e);
}
@@ -106,7 +108,8 @@ public class LogSender {
String url = BASE_URL + "?ships=" + encodedMessage + "&color=" + encodedColor;
sendGetRequest(url);
Log.d(TAG, "Ship update лог отправлен: " + message + " (цвет: " + vesselColor + ")");
// Убираем лишние логи
// Log.d(TAG, "Ship update лог отправлен: " + message + " (цвет: " + vesselColor + ")");
} catch (Exception e) {
Log.e(TAG, "Ошибка отправки ship update лога: " + e.getMessage(), e);
}
@@ -182,7 +185,8 @@ public class LogSender {
// Форматируем в HEX
String color = String.format("#%02X%02X%02X", r, g, b);
Log.d(TAG, "Сгенерирован цвет для MMSI " + mmsi + ": " + color + " (RGB: " + r + "," + g + "," + b + ")");
// Убираем лишние логи
// Log.d(TAG, "Сгенерирован цвет для MMSI " + mmsi + ": " + color + " (RGB: " + r + "," + g + "," + b + ")");
return color;
@@ -315,9 +319,9 @@ public class LogSender {
.replace("'", "%27")
.replace("#", "%23");
// Логируем для отладки
Log.d(TAG, "Исходное сообщение: " + message);
Log.d(TAG, "Закодированное сообщение: " + encoded);
// Убираем лишние логи
// Log.d(TAG, "Исходное сообщение: " + message);
// Log.d(TAG, "Закодированное сообщение: " + encoded);
return encoded;
} catch (Exception e) {
@@ -342,8 +346,8 @@ public class LogSender {
private static void sendGetRequest(String urlString) {
HttpURLConnection connection = null;
try {
// Логируем полный URL для отладки
Log.d(TAG, "Отправляем GET запрос на: " + urlString);
// Убираем лишние логи
// Log.d(TAG, "Отправляем GET запрос на: " + urlString);
@SuppressWarnings("deprecation")
URL url = new URL(urlString);
@@ -355,7 +359,8 @@ public class LogSender {
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
Log.d(TAG, "Лог успешно отправлен, код ответа: " + responseCode);
// Убираем лишние логи
// Log.d(TAG, "Лог успешно отправлен, код ответа: " + responseCode);
} else {
Log.w(TAG, "Лог отправлен с предупреждением, код ответа: " + responseCode);
}
@@ -0,0 +1,127 @@
package com.grigowashere.aismap.utils;
/**
* Утилиты для навигационных вычислений
*/
public class NavigationUtils {
// Радиус Земли в метрах
private static final double EARTH_RADIUS_METERS = 6371000.0;
/**
* Вычисляет расстояние между двумя точками на Земле (формула гаверсинуса)
* @param lat1 широта первой точки в градусах
* @param lon1 долгота первой точки в градусах
* @param lat2 широта второй точки в градусах
* @param lon2 долгота второй точки в градусах
* @return расстояние в метрах
*/
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
// Проверяем валидность координат
if (lat1 == 0 && lon1 == 0) return -1;
if (lat2 == 0 && lon2 == 0) return -1;
// Преобразуем градусы в радианы
double lat1Rad = Math.toRadians(lat1);
double lon1Rad = Math.toRadians(lon1);
double lat2Rad = Math.toRadians(lat2);
double lon2Rad = Math.toRadians(lon2);
// Разности координат
double deltaLat = lat2Rad - lat1Rad;
double deltaLon = lon2Rad - lon1Rad;
// Формула гаверсинуса
double a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
Math.cos(lat1Rad) * Math.cos(lat2Rad) *
Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return EARTH_RADIUS_METERS * c;
}
/**
* Вычисляет азимут (bearing) от первой точки ко второй
* @param lat1 широта первой точки в градусах
* @param lon1 долгота первой точки в градусах
* @param lat2 широта второй точки в градусах
* @param lon2 долгота второй точки в градусах
* @return азимут в градусах (0-360)
*/
public static double calculateBearing(double lat1, double lon1, double lat2, double lon2) {
// Проверяем валидность координат
if (lat1 == 0 && lon1 == 0) return -1;
if (lat2 == 0 && lon2 == 0) return -1;
// Преобразуем градусы в радианы
double lat1Rad = Math.toRadians(lat1);
double lon1Rad = Math.toRadians(lon1);
double lat2Rad = Math.toRadians(lat2);
double lon2Rad = Math.toRadians(lon2);
// Разности координат
double deltaLon = lon2Rad - lon1Rad;
// Вычисляем азимут
double y = Math.sin(deltaLon) * Math.cos(lat2Rad);
double x = Math.cos(lat1Rad) * Math.sin(lat2Rad) -
Math.sin(lat1Rad) * Math.cos(lat2Rad) * Math.cos(deltaLon);
double bearingRad = Math.atan2(y, x);
double bearingDeg = Math.toDegrees(bearingRad);
// Нормализуем к диапазону 0-360
return (bearingDeg + 360) % 360;
}
/**
* Вычисляет относительный азимут (сколько градусов влево/вправо от нашего курса)
* @param ourCourse наш курс в градусах (0-360)
* @param targetBearing азимут до цели в градусах (0-360)
* @return относительный азимут в градусах (-180 до +180, отрицательное = влево, положительное = вправо)
*/
public static double calculateRelativeBearing(double ourCourse, double targetBearing) {
if (ourCourse < 0 || targetBearing < 0) return -1;
double relativeBearing = targetBearing - ourCourse;
// Нормализуем к диапазону -180 до +180
while (relativeBearing > 180) relativeBearing -= 360;
while (relativeBearing < -180) relativeBearing += 360;
return relativeBearing;
}
/**
* Форматирует расстояние для отображения
* @param distanceMeters расстояние в метрах
* @return отформатированная строка
*/
public static String formatDistance(double distanceMeters) {
if (distanceMeters < 0) return "--";
if (distanceMeters < 1000) {
return String.format("%.0f м", distanceMeters);
} else {
return String.format("%.1f км", distanceMeters / 1000.0);
}
}
/**
* Форматирует относительный азимут для отображения
* @param relativeBearing относительный азимут в градусах
* @return отформатированная строка
*/
public static String formatRelativeBearing(double relativeBearing) {
// Проверяем на невалидные значения
if (relativeBearing < -180 || relativeBearing > 180) return "--";
if (Math.abs(relativeBearing) < 1) {
return "прямо";
} else if (relativeBearing > 0) {
return String.format("%.0f° вправо", relativeBearing);
} else {
return String.format("%.0f° влево", Math.abs(relativeBearing));
}
}
}
@@ -26,8 +26,12 @@ public class SettingsManager {
private static final String KEY_PREDICTION_COLOR = "prediction_color";
private static final String KEY_PATH_WIDTH = "path_width";
private static final String KEY_PREDICTION_WIDTH = "prediction_width";
private static final String KEY_PATH_MAX_POINTS = "path_max_points";
private static final String KEY_PREDICTION_HORIZON_SEC = "prediction_horizon_sec";
private static final String KEY_VIBRATION_ENABLED = "vibration_enabled";
private static final String KEY_SOUND_ENABLED = "sound_enabled";
private static final String KEY_KEEP_SCREEN_ON_ENABLED = "keep_screen_on_enabled";
private static final String KEY_CURSOR_ENABLED = "cursor_enabled";
// Значения по умолчанию
private static final int DEFAULT_UDP_PORT = 10110;
@@ -42,8 +46,12 @@ public class SettingsManager {
private static final int DEFAULT_PREDICTION_COLOR = 0xFFFFFF00; // Желтый
private static final float DEFAULT_PATH_WIDTH = 3.0f;
private static final float DEFAULT_PREDICTION_WIDTH = 2.0f;
private static final int DEFAULT_PATH_MAX_POINTS = 100; // Уменьшено с 300 до 100 для предотвращения зависаний
private static final int DEFAULT_PREDICTION_HORIZON_SEC = 60;
private static final boolean DEFAULT_VIBRATION_ENABLED = true;
private static final boolean DEFAULT_SOUND_ENABLED = true;
private static final boolean DEFAULT_KEEP_SCREEN_ON_ENABLED = true;
private static final boolean DEFAULT_CURSOR_ENABLED = false;
// Режимы работы с данными
public static final String DATA_MODE_HYBRID = "hybrid";
@@ -185,9 +193,30 @@ public class SettingsManager {
.putInt(KEY_DATA_STALE_REMOVE_MINUTES, DEFAULT_DATA_STALE_REMOVE_MINUTES)
.putBoolean(KEY_VIBRATION_ENABLED, DEFAULT_VIBRATION_ENABLED)
.putBoolean(KEY_SOUND_ENABLED, DEFAULT_SOUND_ENABLED)
.putBoolean(KEY_KEEP_SCREEN_ON_ENABLED, DEFAULT_KEEP_SCREEN_ON_ENABLED)
.apply();
Log.i(TAG, "Настройки сброшены к значениям по умолчанию");
}
public int getPathMaxPoints() {
return prefs.getInt(KEY_PATH_MAX_POINTS, DEFAULT_PATH_MAX_POINTS);
}
public void setPathMaxPoints(int maxPoints) {
if (maxPoints < 10) maxPoints = 10;
if (maxPoints > 10000) maxPoints = 10000;
prefs.edit().putInt(KEY_PATH_MAX_POINTS, maxPoints).apply();
}
public int getPredictionHorizonSec() {
return prefs.getInt(KEY_PREDICTION_HORIZON_SEC, DEFAULT_PREDICTION_HORIZON_SEC);
}
public void setPredictionHorizonSec(int seconds) {
if (seconds < 5) seconds = 5;
if (seconds > 3600) seconds = 3600;
prefs.edit().putInt(KEY_PREDICTION_HORIZON_SEC, seconds).apply();
}
/**
* Получает все настройки в виде строки для отладки
@@ -375,4 +404,35 @@ public class SettingsManager {
prefs.edit().putBoolean(KEY_SOUND_ENABLED, enabled).apply();
Log.i(TAG, "Звук при обнаружении новых AIS целей: " + (enabled ? "включен" : "выключен"));
}
/**
* Проверяет, включен ли режим "не засыпать" для экрана
*/
public boolean isKeepScreenOnEnabled() {
return prefs.getBoolean(KEY_KEEP_SCREEN_ON_ENABLED, DEFAULT_KEEP_SCREEN_ON_ENABLED);
}
/**
* Включает/выключает режим "не засыпать" для экрана
*/
public void setKeepScreenOnEnabled(boolean enabled) {
prefs.edit().putBoolean(KEY_KEEP_SCREEN_ON_ENABLED, enabled).apply();
Log.i(TAG, "Режим 'не засыпать' для экрана: " + (enabled ? "включен" : "выключен"));
}
/**
* Проверяет, включен ли курсор на карте
*/
public boolean isCursorEnabled() {
return prefs.getBoolean(KEY_CURSOR_ENABLED, DEFAULT_CURSOR_ENABLED);
}
/**
* Включает/выключает курсор на карте
*/
public void setCursorEnabled(boolean enabled) {
prefs.edit().putBoolean(KEY_CURSOR_ENABLED, enabled).apply();
Log.i(TAG, "Курсор на карте: " + (enabled ? "включен" : "выключен"));
}
}
@@ -158,7 +158,7 @@ public class CoordinatesDockWidget extends BaseDockWidget {
testPaint.setTextSize(dp(16));
testPaint.setTypeface(android.graphics.Typeface.DEFAULT_BOLD);
testPaint.setAntiAlias(true);
canvas.drawText("КООРДИНАТЫ", dp(16), dp(20), testPaint);
// canvas.drawText("КООРДИНАТЫ", dp(16), dp(20), testPaint);
// Рисуем текст
canvas.drawText(coordinatesText, dp(16), startY, coordinatesPaint);
@@ -0,0 +1,276 @@
package com.grigowashere.aismap.view;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.grigowashere.aismap.R;
import com.grigowashere.aismap.models.Vessel;
import com.grigowashere.aismap.models.AISVessel;
/**
* Overlay для отображения курсора на карте с координатами и информацией о расстоянии
*/
public class CursorOverlay {
private Context context;
private View overlayView;
private TextView tvCursorLatitude;
private TextView tvCursorLongitude;
private TextView tvDistance;
private TextView tvBearing;
private LinearLayout coordinatesPanel;
private LinearLayout distanceBearingPanel;
private LinearLayout aisVesselInfoPanel;
// AIS vessel info TextViews
private TextView tvAisMmsi;
private TextView tvAisName;
private TextView tvAisCallSign;
private TextView tvAisCog;
private TextView tvAisSog;
private Vessel ownVessel;
private AISVessel currentAisVessel;
private double cursorLatitude;
private double cursorLongitude;
public CursorOverlay(Context context) {
this.context = context;
initializeViews();
}
private void initializeViews() {
LayoutInflater inflater = LayoutInflater.from(context);
overlayView = inflater.inflate(R.layout.cursor, null);
tvCursorLatitude = overlayView.findViewById(R.id.tv_cursor_latitude);
tvCursorLongitude = overlayView.findViewById(R.id.tv_cursor_longitude);
tvDistance = overlayView.findViewById(R.id.tv_distance);
tvBearing = overlayView.findViewById(R.id.tv_bearing);
coordinatesPanel = overlayView.findViewById(R.id.coordinates_panel);
distanceBearingPanel = overlayView.findViewById(R.id.distance_bearing_panel);
aisVesselInfoPanel = overlayView.findViewById(R.id.ais_vessel_info_panel);
// Initialize AIS vessel info TextViews
tvAisMmsi = overlayView.findViewById(R.id.tv_ais_mmsi);
tvAisName = overlayView.findViewById(R.id.tv_ais_name);
tvAisCallSign = overlayView.findViewById(R.id.tv_ais_call_sign);
tvAisCog = overlayView.findViewById(R.id.tv_ais_cog);
tvAisSog = overlayView.findViewById(R.id.tv_ais_sog);
// По умолчанию курсор скрыт
overlayView.setVisibility(View.GONE);
}
public View getView() {
return overlayView;
}
/**
* Обновляет координаты курсора (центра экрана)
*/
public void updateCursorCoordinates(double latitude, double longitude) {
this.cursorLatitude = latitude;
this.cursorLongitude = longitude;
tvCursorLatitude.setText(String.format("%.6f°", latitude));
tvCursorLongitude.setText(String.format("%.6f°", longitude));
// Обновляем информацию о расстоянии и пеленге, если есть данные о нашем судне
updateDistanceAndBearing();
}
/**
* Устанавливает данные о нашем судне для расчета расстояния и пеленга
*/
public void setOwnVessel(Vessel vessel) {
this.ownVessel = vessel;
updateDistanceAndBearing();
}
/**
* Обновляет информацию о расстоянии и пеленге
*/
private void updateDistanceAndBearing() {
if (ownVessel != null && isValidPosition(ownVessel)) {
double distance = calculateDistance(
ownVessel.getLatitude(), ownVessel.getLongitude(),
cursorLatitude, cursorLongitude
);
// Вычисляем пеленг от судна к курсору
double bearingToCursor = calculateBearing(
ownVessel.getLatitude(), ownVessel.getLongitude(),
cursorLatitude, cursorLongitude
);
// Вычисляем относительный пеленг (на сколько градусов повернуть от курса судна)
double relativeBearing;
if (ownVessel.getCourse() > 0) {
// Пеленг относительно курса судна
relativeBearing = bearingToCursor - ownVessel.getCourse();
// Нормализуем в диапазон -180..+180
while (relativeBearing > 180) relativeBearing -= 360;
while (relativeBearing < -180) relativeBearing += 360;
} else {
// Если курс неизвестен, показываем абсолютный пеленг
relativeBearing = bearingToCursor;
}
// Форматируем расстояние: в км с дробной частью если > 1000м, иначе в метрах
String distanceText;
if (distance >= 1000) {
distanceText = String.format("Rng: %.2f км", distance / 1000.0);
} else {
distanceText = String.format("Rng: %.1f м", distance);
}
tvDistance.setText(distanceText);
tvBearing.setText(String.format("Brg: %.1f°", relativeBearing));
// Показываем информацию о расстоянии и пеленге
tvDistance.setVisibility(View.VISIBLE);
tvBearing.setVisibility(View.VISIBLE);
} else {
// Скрываем информацию, если нет валидных координат нашего судна
tvDistance.setVisibility(View.GONE);
tvBearing.setVisibility(View.GONE);
}
}
/**
* Вычисляет расстояние между двумя точками в метрах (формула гаверсинуса)
*/
private double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
final int R = 6371000; // Радиус Земли в метрах
double lat1Rad = Math.toRadians(lat1);
double lat2Rad = Math.toRadians(lat2);
double deltaLatRad = Math.toRadians(lat2 - lat1);
double deltaLonRad = Math.toRadians(lon2 - lon1);
double a = Math.sin(deltaLatRad / 2) * Math.sin(deltaLatRad / 2) +
Math.cos(lat1Rad) * Math.cos(lat2Rad) *
Math.sin(deltaLonRad / 2) * Math.sin(deltaLonRad / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return R * c;
}
/**
* Вычисляет пеленг от первой точки ко второй в градусах
*/
private double calculateBearing(double lat1, double lon1, double lat2, double lon2) {
double lat1Rad = Math.toRadians(lat1);
double lat2Rad = Math.toRadians(lat2);
double deltaLonRad = Math.toRadians(lon2 - lon1);
double y = Math.sin(deltaLonRad) * Math.cos(lat2Rad);
double x = Math.cos(lat1Rad) * Math.sin(lat2Rad) -
Math.sin(lat1Rad) * Math.cos(lat2Rad) * Math.cos(deltaLonRad);
double bearing = Math.toDegrees(Math.atan2(y, x));
return (bearing + 360) % 360; // Нормализуем в диапазон 0-360
}
/**
* Скрывает курсор
*/
public void hideCursor() {
if (overlayView != null) {
overlayView.setVisibility(View.GONE);
}
}
/**
* Показывает курсор
*/
public void showCursor() {
if (overlayView != null) {
overlayView.setVisibility(View.VISIBLE);
}
}
/**
* Устанавливает информацию об AIS судне под курсором
*/
public void setAisVesselInfo(AISVessel vessel) {
this.currentAisVessel = vessel;
updateAisVesselInfo();
}
/**
* Обновляет отображение информации об AIS судне
*/
private void updateAisVesselInfo() {
if (currentAisVessel != null) {
// MMSI
tvAisMmsi.setText("MMSI: " + currentAisVessel.getMmsi());
// Название
String name = currentAisVessel.getVesselName();
if (name != null && !name.trim().isEmpty()) {
tvAisName.setText("Название: " + name);
tvAisName.setVisibility(View.VISIBLE);
} else {
tvAisName.setVisibility(View.GONE);
}
// Позывной
String callSign = currentAisVessel.getCallSign();
if (callSign != null && !callSign.trim().isEmpty()) {
tvAisCallSign.setText("Позывной: " + callSign);
tvAisCallSign.setVisibility(View.VISIBLE);
} else {
tvAisCallSign.setVisibility(View.GONE);
}
// COG (курс)
if (currentAisVessel.getCourse() > 0) {
tvAisCog.setText(String.format("COG: %.1f°", currentAisVessel.getCourse()));
tvAisCog.setVisibility(View.VISIBLE);
} else {
tvAisCog.setVisibility(View.GONE);
}
// SOG (скорость)
if (currentAisVessel.getSpeed() > 0) {
tvAisSog.setText(String.format("SOG: %.1f уз", currentAisVessel.getSpeed()));
tvAisSog.setVisibility(View.VISIBLE);
} else {
tvAisSog.setVisibility(View.GONE);
}
// Показываем панель
aisVesselInfoPanel.setVisibility(View.VISIBLE);
} else {
// Скрываем панель
aisVesselInfoPanel.setVisibility(View.GONE);
}
}
/**
* Очищает информацию об AIS судне
*/
public void clearAisVesselInfo() {
this.currentAisVessel = null;
aisVesselInfoPanel.setVisibility(View.GONE);
}
/**
* Проверяет валидность позиции судна
*/
private boolean isValidPosition(Vessel vessel) {
if (vessel == null) return false;
double lat = vessel.getLatitude();
double lon = vessel.getLongitude();
// Проверяем, что координаты в допустимых пределах
return lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180 &&
lat != 0.0 && lon != 0.0; // Исключаем нулевые координаты
}
}
+21
View File
@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="62.13dp"
android:height="77.5dp"
android:viewportWidth="62.13"
android:viewportHeight="77.5">
<path
android:pathData="M31.09,13m-9.5,0a9.5,9.5 0,1 1,19 0a9.5,9.5 0,1 1,-19 0"
android:strokeWidth="7"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M3.09,45.5l4.79,9.05c14.4,27.2 34.78,25.73 48.48,-3.49l2.6,-5.56"
android:strokeWidth="7"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M31.09,22.5L31.09,71"
android:strokeWidth="7"
android:fillColor="#fff"
android:strokeColor="#000"/>
</vector>
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="129dp"
android:height="129dp"
android:viewportWidth="129"
android:viewportHeight="129">
<path
android:pathData="M62.39,72.13L12.02,122.94c-1.86,1.87 -0.53,5.06 2.11,5.06h100.75c2.64,0 3.97,-3.19 2.11,-5.06l-50.38,-50.81c-1.16,-1.17 -3.06,-1.17 -4.22,0Z"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000"/>
<path
android:pathData="M56.87,62.39L6.06,12.02c-1.87,-1.86 -5.06,-0.53 -5.06,2.11v100.75c0,2.64 3.19,3.97 5.06,2.11l50.81,-50.38c1.17,-1.16 1.17,-3.06 0,-4.22Z"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000"/>
<path
android:pathData="M66.61,56.87L116.98,6.06c1.86,-1.87 0.53,-5.06 -2.11,-5.06H14.12c-2.64,0 -3.97,3.19 -2.11,5.06l50.38,50.81c1.16,1.17 3.06,1.17 4.22,0Z"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000"/>
<path
android:pathData="M72.13,66.61l50.81,50.38c1.87,1.86 5.06,0.53 5.06,-2.11V14.12c0,-2.64 -3.19,-3.97 -5.06,-2.11l-50.81,50.38c-1.17,1.16 -1.17,3.06 0,4.22Z"
android:strokeWidth="4"
android:fillColor="#00000000"
android:strokeColor="#000"/>
</vector>
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Горизонтальная линия креста -->
<item android:top="18dp" android:bottom="18dp">
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
<size android:width="40dp" android:height="4dp" />
</shape>
</item>
<!-- Вертикальная линия креста -->
<item android:left="18dp" android:right="18dp">
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
<size android:width="4dp" android:height="40dp" />
</shape>
</item>
<!-- Центральная точка -->
<item android:left="18dp" android:right="18dp" android:top="18dp" android:bottom="18dp">
<shape android:shape="oval">
<solid android:color="#FFFFFF" />
<size android:width="4dp" android:height="4dp" />
</shape>
</item>
</layer-list>
+62
View File
@@ -0,0 +1,62 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="137.43dp"
android:height="137.43dp"
android:viewportWidth="137.43"
android:viewportHeight="137.43">
<path
android:strokeWidth="1"
android:pathData="M69.22,68.97m-15.5,0a15.5,15.5 0,1 1,31 0a15.5,15.5 0,1 1,-31 0"
android:fillColor="#00000000"
android:strokeColor="#000"/>
<path
android:fillColor="#FF000000"
android:pathData="M50.01,71.14l-6,-0.28l-0.02,-4.4l6,-0.32l0.02,5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M31.34,70.27l-12.67,-0.59l-0.01,-1.86l12.67,-0.68l0.01,3.13z"/>
<path
android:fillColor="#FF000000"
android:pathData="M6,69.09l-6,-0.27l6,-0.33l0,0.6z"/>
<path
android:fillColor="#FF000000"
android:pathData="M66.29,50.01l0.28,-6l4.4,-0.02l0.32,6l-5,0.02z"/>
<path
android:fillColor="#FF000000"
android:pathData="M67.16,31.34l0.59,-12.67l1.87,-0.01l0.68,12.67l-3.14,0.01z"/>
<path
android:fillColor="#FF000000"
android:pathData="M68.34,6l0.28,-6l0.32,6l-0.6,0z"/>
<path
android:fillColor="#FF000000"
android:pathData="M87.43,66.29l6,0.28l0.01,4.4l-6,0.32l-0.01,-5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M106.1,67.16l12.66,0.59l0.01,1.87l-12.66,0.68l-0.01,-3.14z"/>
<path
android:fillColor="#FF000000"
android:pathData="M131.43,68.34l6,0.28l-5.99,0.32l-0.01,-0.6z"/>
<path
android:fillColor="#FF000000"
android:pathData="M71.14,87.43l-0.28,6l-4.4,0.01l-0.32,-6l5,-0.01z"/>
<path
android:fillColor="#FF000000"
android:pathData="M70.27,106.1l-0.59,12.66l-1.86,0.01l-0.68,-12.66l3.13,-0.01z"/>
<path
android:fillColor="#FF000000"
android:pathData="M69.09,131.43l-0.27,6l-0.33,-5.99l0.6,-0.01z"/>
<path
android:fillColor="#FF000000"
android:pathData="M69.26,70.79c1.93,0 1.93,-3 0,-3s-1.93,3 0,3h0Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M80.01,134.2c-0.42,-4.29 -0.71,-8.58 -1.01,-12.86 0.01,-6.42 0,-19.31 0,-25.73 0,0 0,-3.22 0,-3.22v-1.61c-0.03,-2.95 1.19,-5.88 3.31,-7.94 1.69,-1.64 3.92,-2.74 6.27,-3.02 2.05,-0.21 4.54,-0.04 6.55,-0.09 0,0 12.86,0 12.86,0h12.86c4.29,0.34 8.58,0.59 12.86,1 -4.29,0.41 -8.58,0.66 -12.86,1 -6.42,0 -19.31,0 -25.73,0 -1.77,0.05 -4.64,-0.1 -6.3,0.08 -1.92,0.23 -3.73,1.12 -5.12,2.47 -1.74,1.7 -2.72,4.08 -2.7,6.51 0,0 0,1.61 0,1.61 0,0 0,3.22 0,3.22 0,6.41 0,19.32 0,25.73 -0.29,4.29 -0.59,8.58 -1.01,12.86h0Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M4.26,79.75c4.29,-0.42 8.58,-0.71 12.86,-1.01 6.42,0.01 19.31,0 25.73,0 0,0 3.22,0 3.22,0h1.61c2.95,-0.03 5.88,1.19 7.94,3.31 1.64,1.69 2.74,3.92 3.02,6.27 0.21,2.05 0.04,4.54 0.09,6.55 0,0 0,12.86 0,12.86v12.86c-0.34,4.29 -0.59,8.58 -1,12.86 -0.41,-4.29 -0.66,-8.58 -1,-12.86 0,-6.42 0,-19.31 0,-25.73 -0.05,-1.77 0.1,-4.64 -0.08,-6.3 -0.23,-1.92 -1.12,-3.73 -2.47,-5.12 -1.7,-1.74 -4.08,-2.72 -6.51,-2.7 0,0 -1.61,0 -1.61,0 0,0 -3.22,0 -3.22,0 -6.41,0 -19.32,0 -25.73,0 -4.29,-0.29 -8.58,-0.59 -12.86,-1.01h0Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M58.72,4c0.42,4.29 0.71,8.58 1.01,12.86 -0.01,6.42 0,19.31 0,25.73 0,0 0,3.22 0,3.22v1.61c0.03,2.95 -1.19,5.88 -3.31,7.94 -1.69,1.64 -3.92,2.74 -6.27,3.02 -2.05,0.21 -4.54,0.04 -6.55,0.09 0,0 -12.86,0 -12.86,0h-12.86c-4.29,-0.34 -8.58,-0.59 -12.86,-1 4.29,-0.41 8.58,-0.66 12.86,-1 6.42,0 19.31,0 25.73,0 1.77,-0.05 4.64,0.1 6.3,-0.08 1.92,-0.23 3.73,-1.12 5.12,-2.47 1.74,-1.7 2.72,-4.08 2.7,-6.51 0,0 0,-1.61 0,-1.61 0,0 0,-3.22 0,-3.22 0,-6.41 0,-19.32 0,-25.73 0.29,-4.29 0.59,-8.58 1.01,-12.86h0Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M134.46,58.46c-4.29,0.42 -8.58,0.71 -12.86,1.01 -6.42,-0.01 -19.31,0 -25.73,0 0,0 -3.22,0 -3.22,0h-1.61c-2.95,0.03 -5.88,-1.19 -7.94,-3.31 -1.64,-1.69 -2.74,-3.92 -3.02,-6.27 -0.21,-2.05 -0.04,-4.54 -0.09,-6.55 0,0 0,-12.86 0,-12.86v-12.86c0.34,-4.29 0.59,-8.58 1,-12.86 0.41,4.29 0.66,8.58 1,12.86 0,6.42 0,19.31 0,25.73 0.05,1.77 -0.1,4.64 0.08,6.3 0.23,1.92 1.12,3.73 2.47,5.12 1.7,1.74 4.08,2.72 6.51,2.7 0,0 1.61,0 1.61,0 0,0 3.22,0 3.22,0 6.41,0 19.32,0 25.73,0 4.29,0.29 8.58,0.59 12.86,1.01h0Z"/>
</vector>
+61
View File
@@ -0,0 +1,61 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="62.24dp"
android:height="62.18dp"
android:viewportWidth="62.24"
android:viewportHeight="62.18">
<path
android:pathData="M30.66,31.22m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M27.25,41.64l-9.4,7.49c-2.27,1.81 -5.4,2.07 -7.94,0.66l-1.42,-0.78c-2.91,-1.61 -2.83,-5.83 0.15,-7.32l7.01,-3.52 11.59,3.47Z"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M19.94,31.19l-10.03,-6.62c-2.42,-1.6 -3.64,-4.5 -3.08,-7.34l0.31,-1.59c0.63,-3.27 4.67,-4.49 7.01,-2.12l5.51,5.58 0.28,12.1Z"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M27.61,21l3.2,-11.58c0.77,-2.79 3.15,-4.85 6.03,-5.2l1.61,-0.2c3.3,-0.41 5.71,3.05 4.18,6.01l-3.6,6.97 -11.42,4.01Z"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M39.68,25.15l12.01,-0.54c2.9,-0.13 5.59,1.5 6.81,4.13l0.68,1.47c1.41,3.02 -1.14,6.37 -4.42,5.83l-7.74,-1.27 -7.34,-9.62Z"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M39.46,37.91l4.22,11.25c1.02,2.71 0.3,5.78 -1.82,7.75l-1.18,1.1c-2.43,2.27 -6.41,0.89 -6.92,-2.4l-1.18,-7.75 6.88,-9.95Z"
android:strokeWidth="4"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M57.93,41.9l-2.71,4.16s3.31,-2.54 2.71,-4.16Z"
android:strokeWidth="4"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M29.15,59.9l-4.8,-1.29s3.44,2.36 4.8,1.29Z"
android:strokeWidth="4"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M3.13,38.09l-0.25,-4.96s-1.19,4 0.25,4.96Z"
android:strokeWidth="4"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M15.84,6.6l4.64,-1.77s-4.17,0.11 -4.64,1.77Z"
android:strokeWidth="4"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M49.71,8.96l3.12,3.87s-1.39,-3.93 -3.12,-3.87Z"
android:strokeWidth="4"
android:fillColor="#fff"
android:strokeColor="#000"/>
</vector>
+22
View File
@@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="45.83dp"
android:height="65.94dp"
android:viewportWidth="45.83"
android:viewportHeight="65.94">
<path
android:pathData="M41.75,62.87V4.78l-3.87,2.32 -6.48,3.89c-9.59,5.76 -17.51,13.94 -22.94,23.72l-6.71,12.07"
android:fillColor="#00FFFFFF"/>
<path
android:fillColor="#FF000000"
android:pathData="M41.56,62.87c0,-16.54 0.05,-34.31 -0.59,-50.83 -0.1,-2.42 -0.17,-4.84 -1.23,-7.26 0,0 3.03,1.71 3.03,1.71 -3.66,2.26 -9.09,5.36 -12.6,7.63 -7.99,5.26 -14.73,12.41 -19.49,20.71 0,0 -7.19,12.91 -7.19,12.91 0,0 -3.5,-1.94 -3.5,-1.94 0,0 7.22,-12.97 7.22,-12.97 5.07,-8.83 12.25,-16.45 20.75,-22.05 5.53,-3.51 12.26,-7.38 17.85,-10.79 0,0 -2.08,4.78 -2.08,4.78 -1.8,4.72 -1.15,9.64 -1.49,14.52 -0.19,8.41 -0.24,20.51 -0.33,29.04 -0.02,4.84 -0.03,9.68 0.01,14.52h-0.37Z"/>
<path
android:pathData="M41.47,62.28m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0"
android:strokeWidth=".5"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M41.47,63.28v1.8h0c-0.51,0.74 -1.58,0.81 -2.18,0.14l-0.27,-0.31"
android:strokeWidth=".5"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
</vector>
+26
View File
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="107dp"
android:height="127.1dp"
android:viewportWidth="107"
android:viewportHeight="127.1">
<path
android:pathData="M0,115.1L43,115.1"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M64,115.1L107,115.1"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M95,8.1l-12.08,-6.7 -35.92,80.7L15,115.1s11.69,-0.03 28,0c0,0 1,-10 11,-10 9,0 10,10 10,10 9.54,0.02 15.06,0 15,0l-5,-29L95,8.1Z"
android:strokeWidth="2"
android:fillColor="#00ff00"
android:strokeColor="#000"/>
<path
android:pathData="M53.5,115.6m-10.5,0a10.5,10.5 0,1 1,21 0a10.5,10.5 0,1 1,-21 0"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000"/>
</vector>
+26
View File
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="37.67dp"
android:height="44.99dp"
android:viewportWidth="37.67"
android:viewportHeight="44.99">
<path
android:pathData="M6.71,43.99V8.86H2.32l6.3,-6.67c0.7,-0.74 1.66,-1.16 2.68,-1.16l14.07,-0.04c1.5,0 2.93,0.6 3.97,1.68l5.97,6.18h-4.6l1,35.13H6.71Z"
android:strokeWidth="2"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M4.21,16.49L33.21,20.49"
android:strokeWidth="2"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M4.21,20.49L33.21,24.12"
android:strokeWidth="2"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:pathData="M4.21,24.12L33.21,27.84"
android:strokeWidth="2"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
</vector>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#80000000" />
<corners android:radius="8dp" />
<stroke
android:width="1dp"
android:color="#40FFFFFF" />
</shape>
+26
View File
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="107dp"
android:height="127.1dp"
android:viewportWidth="107"
android:viewportHeight="127.1">
<path
android:pathData="M0,115.1L43,115.1"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M64,115.1L107,115.1"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M95,8.1l-12.08,-6.7 -35.92,80.7L15,115.1s11.69,-0.03 28,0c0,0 1,-10 11,-10 9,0 10,10 10,10 9.54,0.02 15.06,0 15,0l-5,-29L95,8.1Z"
android:strokeWidth="2"
android:fillColor="#ff0000"
android:strokeColor="#000"/>
<path
android:pathData="M53.5,115.6m-10.5,0a10.5,10.5 0,1 1,21 0a10.5,10.5 0,1 1,-21 0"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000"/>
</vector>
+26
View File
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50.57dp"
android:height="51.98dp"
android:viewportWidth="50.57"
android:viewportHeight="51.98">
<path
android:pathData="M21.49,2.23l0,20.35l0.3,29.39"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:pathData="M0.79,41.97L50.57,41.97"
android:strokeWidth="2"
android:fillColor="#fff"
android:strokeColor="#000"/>
<path
android:strokeWidth="1"
android:pathData="M25.68,2.23l0,35.8l23.13,0l-23.13,-35.8z"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
<path
android:strokeWidth="1"
android:pathData="M17.7,2.23l0,35.8l-16.91,0l16.91,-35.8z"
android:fillColor="#00FFFFFF"
android:strokeColor="#000"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#D9913C"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#3A6EA5"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#1D3557"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#B5B8B1"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#2BA9E0"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#35C2A9"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#C23B22"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="88.5dp"
android:height="152.73dp"
android:viewportWidth="88.5"
android:viewportHeight="152.73">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="9"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M44.25,6.77l-39.75,44.69l0,96.77l79.5,0l0,-96.77l-39.75,-44.69z"
android:strokeWidth="3"
android:fillColor="#E7621B"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#D9913C"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#3A6EA5"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#1D3557"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#B5B8B1"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#2BA9E0"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#35C2A9"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#C23B22"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="91.38dp"
android:height="162.6dp"
android:viewportWidth="91.38"
android:viewportHeight="162.6">
<!-- Внешняя обводка для контраста -->
<path
android:pathData="M45.69,16.63l-39.75,141.47l79.5,0l-39.75,-141.47z"
android:strokeWidth="12"
android:fillColor="#000000"
android:strokeColor="#000000"/>
<!-- Основная форма с внутренней обводкой -->
<path
android:pathData="M45.69,18.63l-37.75,139.47l75.5,0l-37.75,-139.47z"
android:strokeWidth="3"
android:fillColor="#E7621B"
android:strokeColor="#FFFFFF"/>
</vector>
@@ -4,10 +4,23 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text_target_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AIS цели: 0"
android:textSize="16sp"
android:textStyle="bold"
android:padding="12dp"
android:background="#f0f0f0"
android:textColor="#333333"
android:gravity="center" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_ais_targets"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_empty_state"
+2 -1
View File
@@ -6,7 +6,7 @@
tools:context=".MainActivity">
<!-- Карта -->
<com.yandex.mapkit.mapview.MapView
<org.maplibre.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -64,6 +64,7 @@
android:background="@android:color/white"
android:layout_marginTop="8dp" />
<!-- Строки возраста последних сообщений GPS ($) и AIS (!) -->
<TextView
android:id="@+id/tv_gps_age"
@@ -72,6 +72,143 @@
</com.google.android.material.card.MaterialCardView>
<!-- Треки и предсказание -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🧭 Путь и предсказание"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_marginBottom="12dp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="Максимум точек на судно"
app:helperText="Ограничение размера истории пути">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_path_max_points"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:text="300" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="Толщина линии пути (px)">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_path_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="3.0" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="Цвет пути (#RRGGBB)">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_path_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:text="#00FFFF" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="Толщина линии предсказания (px)">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_prediction_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="2.0" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:hint="Цвет предсказания (#RRGGBB)">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_prediction_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:text="#FFFF00" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:hint="Горизонт предсказания (сек)">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_prediction_horizon_sec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:text="60" />
</com.google.android.material.textfield.TextInputLayout>
<!-- Кнопка очистки трекера пути -->
<Button
android:id="@+id/btn_clear_path"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🗑️ Очистить трекер пути"
android:textSize="16sp"
android:layout_marginTop="8dp"
style="@style/Widget.Material3.Button.OutlinedButton" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Удаляет все сохраненные точки пути собственного судна"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginTop="4dp"
android:layout_marginStart="16dp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Приоритеты данных -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
@@ -284,6 +421,59 @@
</com.google.android.material.card.MaterialCardView>
<!-- Настройки экрана -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="📱 Управление экраном"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_marginBottom="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Настройте поведение экрана во время навигации:"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="16dp" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_keep_screen_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Не давать экрану засыпать"
android:textSize="16sp"
android:checked="true"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Экран будет оставаться включенным во время навигации (рекомендуется для навигатора)"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Настройки уведомлений -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
@@ -355,6 +545,59 @@
</com.google.android.material.card.MaterialCardView>
<!-- Настройки курсора -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🎯 Курсор на карте"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:layout_marginBottom="12dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Настройте отображение курсора с координатами центра экрана:"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="16dp" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_cursor_enabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Показать курсор"
android:textSize="16sp"
android:checked="false"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Отображать крест в центре экрана с координатами и информацией о расстоянии"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Кнопки -->
<LinearLayout
android:layout_width="match_parent"
@@ -261,6 +261,30 @@
android:background="@android:color/transparent"
android:padding="8dp" />
<!-- Расстояние до судна -->
<TextView
android:id="@+id/bottom_sheet_ais_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="📏 Расстояние: --"
android:textSize="14sp"
android:textColor="@android:color/black"
android:layout_marginBottom="8dp"
android:background="@android:color/transparent"
android:padding="8dp" />
<!-- Пеленг (азимут) до судна -->
<TextView
android:id="@+id/bottom_sheet_ais_bearing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🧭 Пеленг: --"
android:textSize="14sp"
android:textColor="@android:color/black"
android:layout_marginBottom="8dp"
android:background="@android:color/transparent"
android:padding="8dp" />
<!-- Последнее обновление -->
<TextView
android:id="@+id/bottom_sheet_ais_last_update"
+150
View File
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<!-- Курсор в виде креста в центре экрана -->
<View
android:id="@+id/cursor_cross"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="@drawable/cursorcross" />
<!-- Координаты в первом квадранте (верхний левый) -->
<!-- Расстояние и пеленг в четвертом квадранте (нижний правый) -->
<LinearLayout
android:id="@+id/coordinates_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/panel_background"
android:orientation="vertical"
android:padding="8dp"
android:translationX="-60dp"
android:translationY="-40dp"
android:visibility="visible">
<TextView
android:id="@+id/tv_cursor_latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Широта: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_cursor_longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Долгота: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/distance_bearing_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="120dp"
android:layout_marginTop="60dp"
android:background="@drawable/panel_background"
android:orientation="vertical"
android:padding="8dp"
android:translationX="60dp"
android:translationY="40dp"
android:visibility="visible">
<TextView
android:id="@+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Rnd:"
android:textColor="@android:color/white"
android:textSize="12sp"
android:visibility="gone"
/>
<TextView
android:id="@+id/tv_bearing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Brg: --"
android:textColor="@android:color/white"
android:textSize="12sp"
android:visibility="gone"
/>
</LinearLayout>
<!-- Информация об AIS судне в левом нижнем углу -->
<LinearLayout
android:id="@+id/ais_vessel_info_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/panel_background"
android:orientation="vertical"
android:padding="8dp"
android:translationX="-75dp"
android:translationY="60dp"
android:visibility="gone">
<TextView
android:id="@+id/tv_ais_mmsi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="MMSI: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_ais_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Название: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_ais_call_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="Позывной: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_ais_cog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="COG: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_ais_sog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:text="SOG: --"
android:textColor="@android:color/white"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
@@ -48,6 +48,22 @@
android:textSize="12sp"
android:text="N сек назад" />
<TextView
android:id="@+id/tv_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="Расстояние: --"
android:textColor="#666666" />
<TextView
android:id="@+id/tv_bearing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="Азимут: --"
android:textColor="#666666" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+12
View File
@@ -26,4 +26,16 @@
android:icon="@android:drawable/ic_menu_directions"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_service_test"
android:title="Тест сервиса"
android:icon="@android:drawable/ic_menu_manage"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_keep_screen_on"
android:title="Экран"
android:icon="@android:drawable/ic_menu_view"
app:showAsAction="ifRoom" />
</menu>