+Флаг на карте для синхронизированных обработок

This commit is contained in:
Igor I
2025-02-19 18:54:47 +05:00
parent be8a290d50
commit 0bfba422dc
6 changed files with 107 additions and 15 deletions

View File

@ -13,8 +13,8 @@ android {
defaultConfig { defaultConfig {
applicationId "kz.istt.locust" applicationId "kz.istt.locust"
minSdkVersion 15 minSdkVersion 15
versionCode 106 versionCode 108
versionName "3.0.3" versionName "3.0.5"
targetSdkVersion 34 targetSdkVersion 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true

View File

@ -63,7 +63,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
ArrayList<Polygon> polygons=new ArrayList<Polygon>(); ArrayList<Polygon> polygons=new ArrayList<Polygon>();
Polygon polygon=null; Polygon polygon=null;
String uid=""; String g_uid="";
private Marker marker=null; private Marker marker=null;
private LocationManager lm; private LocationManager lm;
@ -97,10 +97,10 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
.findFragmentById(R.id.map); .findFragmentById(R.id.map);
mapFragment.getMapAsync(this); mapFragment.getMapAsync(this);
Intent intent = getIntent(); Intent intent = getIntent();
points = intent.getParcelableArrayListExtra("LatLon"); points = intent.getParcelableArrayListExtra("LatLon");
uid = intent.getStringExtra("uid"); g_uid = intent.getStringExtra("uid");
if(g_uid==null) g_uid="";
// Чтоб слушать GPS // Чтоб слушать GPS
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
@ -131,7 +131,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
); );
marker.setVisible(false); marker.setVisible(false);
//Геозоны обследования саранчи //Отобразить все геозоны кроме текущей, обследования саранчи (текущие ниже)
DbOpenHelper dboh = new DbOpenHelper(this); DbOpenHelper dboh = new DbOpenHelper(this);
SQLiteDatabase rdb = null; SQLiteDatabase rdb = null;
try { try {
@ -139,12 +139,25 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
rdb = dboh.getReadableDatabase(); rdb = dboh.getReadableDatabase();
Cursor cursor=null; Cursor cursor=null;
try { try {
cursor = rdb.rawQuery("select frmlocust_uid,lat,lon from frmlocust_locations where frmlocust_uid!='" + uid + "' order by frmlocust_uid,pos;", null); String sql = """
select
frmlocust_uid,
lat,
lon
from
frmlocust_locations
where
frmlocust_uid!=?
order by
frmlocust_uid,
pos
""";
cursor = rdb.rawQuery(sql, new String[]{g_uid});
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
String uid = ""; String uid = "";
PolygonOptions pOptions2 = new PolygonOptions(); PolygonOptions pOptions2 = new PolygonOptions();
do { do {
if (!uid.equals(cursor.getString(0)) && pOptions2.getPoints().size() > 1) { if (pOptions2.getPoints().size() > 1) {
Polygon polygon = mMap.addPolygon(pOptions2); Polygon polygon = mMap.addPolygon(pOptions2);
polygons.add(polygon); polygons.add(polygon);
polygon.setFillColor(0x7F0000FF); polygon.setFillColor(0x7F0000FF);
@ -155,6 +168,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
} }
pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2))); pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2)));
} while (cursor.moveToNext()); } while (cursor.moveToNext());
if (pOptions2.getPoints().size() > 1) { if (pOptions2.getPoints().size() > 1) {
Polygon polygon = mMap.addPolygon(pOptions2); Polygon polygon = mMap.addPolygon(pOptions2);
polygons.add(polygon); polygons.add(polygon);
@ -167,10 +181,23 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
if(cursor!=null){ cursor.close(); } if(cursor!=null){ cursor.close(); }
} }
//Геозоны противосаначовой обработки //Отобразить все геозоны кроме текущей, противосаначовой обработки (текущие ниже)
cursor=null; cursor=null;
try { try {
cursor = rdb.rawQuery("select frmlocustdel_uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid!='" + uid + "' order by frmlocustdel_uid,pos;", null); String sql = """
select
frmlocustdel_uid,
lat,
lon
from
frmlocustdel_locations
where
frmlocustdel_uid!=?
order by
frmlocustdel_uid,
pos
""";
cursor = rdb.rawQuery(sql, new String[]{g_uid});
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
String uid = ""; String uid = "";
PolygonOptions pOptions2 = new PolygonOptions(); PolygonOptions pOptions2 = new PolygonOptions();
@ -198,6 +225,40 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
if(cursor!=null){ cursor.close(); } if(cursor!=null){ cursor.close(); }
} }
//Отображаю все центральные точки с анкет противосаранчовой обработки
cursor=null;
try {
String sql = """
select
uid,
lat_center,
lon_center
from
frmlocustdel
where
del = 0
and uid!=?
""";
cursor = rdb.rawQuery(sql, new String[]{g_uid});
if (cursor.moveToFirst()) {
do {
center = new LatLng(cursor.getDouble(1), cursor.getDouble(2));
mMap.addMarker(new MarkerOptions()
.position(center)
.title("Spray")
.icon(BitmapDescriptorFactory.fromBitmap(getMarker(R.drawable.ic_flag)))
);
} while (cursor.moveToNext());
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(cursor!=null){ cursor.close(); }
}
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
}finally{ }finally{
@ -205,7 +266,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
} }
dboh.close(); dboh.close();
/**/ /**/
//Сreating a polygon. (The main polygon at the end since they overlap each) //Create a geopolygon for the current survey. (The main polygon at the end since they overlap each)
PolygonOptions pOptions = new PolygonOptions(); PolygonOptions pOptions = new PolygonOptions();
for(int i=0;i<points.size();i++){ for(int i=0;i<points.size();i++){
@ -213,7 +274,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
pOptions.add(new LatLng(points.get(i).lat, points.get(i).lon)); pOptions.add(new LatLng(points.get(i).lat, points.get(i).lon));
} }
if(pOptions.getPoints().size()>0) { if(!pOptions.getPoints().isEmpty()) {
Polygon polygon = mMap.addPolygon(pOptions); Polygon polygon = mMap.addPolygon(pOptions);
polygon.setFillColor(0x7F00FF00); polygon.setFillColor(0x7F00FF00);
center = getPolygonCenterPoint(pOptions.getPoints()); center = getPolygonCenterPoint(pOptions.getPoints());

View File

@ -14,6 +14,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.InputFilter;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -32,6 +33,8 @@ import com.google.android.gms.vision.barcode.BarcodeDetector;
import java.util.Locale; import java.util.Locale;
import dbfields.InputFilterMinMax;
public class SetupActivity extends Activity { public class SetupActivity extends Activity {
@ -344,6 +347,7 @@ public class SetupActivity extends Activity {
}); });
edtSyncDays = (EditText) findViewById(R.id.edtSyncDays); edtSyncDays = (EditText) findViewById(R.id.edtSyncDays);
edtSyncDays.setFilters(new InputFilter[]{ new InputFilterMinMax(1, 365) });
edtSyncDays.setText(String.valueOf(MySynchronizationOld.SyncDays)); edtSyncDays.setText(String.valueOf(MySynchronizationOld.SyncDays));
edtSyncDays.addTextChangedListener(new TextWatcher() { edtSyncDays.addTextChangedListener(new TextWatcher() {

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="32dp"
android:viewportWidth="25"
android:viewportHeight="32.091168">
<!-- Палка флага -->
<path
android:strokeWidth="1.90167"
android:strokeColor="#000000"
android:fillColor="#000000"
android:strokeLineCap="round"
android:pathData="M5.0213123,29.152388 V2.8006687" />
<!-- Полотнище флага -->
<path
android:strokeWidth="0.614869"
android:strokeColor="#000000"
android:fillColor="#2A2AFF"
android:strokeLineJoin="round"
android:pathData="M5.6552021,4.0684492 C11.994103,6.7851209 15.072998,6.6040094 21.774124,4.2495607 C19.872453,8.052901 19.872453,10.950685 21.774124,14.754026 C15.254111,17.017919 12.627995,17.017919 5.6552021,14.754026 Z" />
</vector>

View File

@ -1,5 +1,9 @@
<vector android:height="48dp" android:viewportHeight="128" <vector
android:viewportWidth="128" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:height="48dp"
android:viewportHeight="128"
android:viewportWidth="128"
android:width="48dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#2d3e50" <path android:fillColor="#2d3e50"
android:pathData="M64.002,3.367c-25.749,0 -43.05,14.759 -43.05,36.725 0,29.112 37.015,81.601 37.383,82.011a7.603,7.603 0,0 0,11.323 0.006c0.374,-0.416 37.389,-52.905 37.389,-82.017C107.048,18.125 89.749,3.367 64.002,3.367ZM64,74.739a28.296,28.296 0,1 1,28.296 -28.296A28.296,28.296 0,0 1,64 74.739Z" android:pathData="M64.002,3.367c-25.749,0 -43.05,14.759 -43.05,36.725 0,29.112 37.015,81.601 37.383,82.011a7.603,7.603 0,0 0,11.323 0.006c0.374,-0.416 37.389,-52.905 37.389,-82.017C107.048,18.125 89.749,3.367 64.002,3.367ZM64,74.739a28.296,28.296 0,1 1,28.296 -28.296A28.296,28.296 0,0 1,64 74.739Z"
android:strokeColor="#ffc6ff" android:strokeWidth="3.8"/> android:strokeColor="#ffc6ff" android:strokeWidth="3.8"/>

View File

@ -281,7 +281,7 @@
android:autofillHints="" android:autofillHints=""
android:ems="10" android:ems="10"
android:importantForAutofill="no" android:importantForAutofill="no"
android:inputType="numberDecimal" /> android:inputType="number" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout