diff --git a/app/build.gradle b/app/build.gradle index e3d7031..b3baf55 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 30 + compileSdkVersion 32 defaultConfig { applicationId "com.example.lezh1k.sensordatacollector" - minSdkVersion 18 - targetSdkVersion 30 + minSdkVersion 23 + targetSdkVersion 32 versionCode 1 versionName "1.0" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' @@ -20,22 +20,23 @@ android { } } compileOptions { - targetCompatibility 1.8 - sourceCompatibility 1.8 + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 } + namespace 'com.example.lezh1k.sensordatacollector' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.constraintlayout:constraintlayout:2.0.2' - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' api group: 'net.sf.marineapi', name: 'marineapi', version: '0.10.0' - api 'com.google.android.gms:play-services-location:17.1.0' - api 'androidx.preference:preference:1.1.1' - implementation 'com.google.android.gms:play-services-maps:17.0.0' + api 'com.google.android.gms:play-services-location:19.0.1' + api 'androidx.preference:preference:1.2.0' + implementation 'com.google.android.gms:play-services-maps:18.0.2' api ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.5@aar') { transitive = true } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee52428..7370e37 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + @@ -19,7 +18,8 @@ + android:configChanges="keyboardHidden|orientation|screenSize" + android:exported="true"> diff --git a/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java b/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java index da07af5..194693a 100644 --- a/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java +++ b/app/src/main/java/com/example/lezh1k/sensordatacollector/MainActivity.java @@ -13,11 +13,6 @@ import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.AppCompatActivity; import android.util.Log; import android.util.TypedValue; import android.view.Menu; @@ -29,6 +24,12 @@ import android.widget.CheckBox; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import com.elvishew.xlog.LogLevel; import com.elvishew.xlog.XLog; import com.elvishew.xlog.printer.AndroidPrinter; @@ -36,15 +37,6 @@ import com.elvishew.xlog.printer.file.FilePrinter; import com.elvishew.xlog.printer.file.backup.FileSizeBackupStrategy; import com.elvishew.xlog.printer.file.naming.FileNameGenerator; -import mad.location.manager.lib.Commons.Utils; -import mad.location.manager.lib.Interfaces.ILogger; -import mad.location.manager.lib.Interfaces.LocationServiceInterface; -import mad.location.manager.lib.Loggers.GeohashRTFilter; -import mad.location.manager.lib.SensorAux.SensorCalibrator; -import mad.location.manager.lib.Services.KalmanLocationService; -import mad.location.manager.lib.Services.ServicesHelper; -import mad.location.manager.lib.Services.Settings; - import com.example.lezh1k.sensordatacollector.Interfaces.MapInterface; import com.example.lezh1k.sensordatacollector.Presenters.MapPresenter; import com.mapbox.mapboxsdk.Mapbox; @@ -64,13 +56,21 @@ import java.util.Locale; import java.util.TimeZone; +import mad.location.manager.lib.Commons.Utils; +import mad.location.manager.lib.Interfaces.ILogger; +import mad.location.manager.lib.Interfaces.LocationServiceInterface; +import mad.location.manager.lib.Loggers.GeohashRTFilter; +import mad.location.manager.lib.SensorAux.SensorCalibrator; +import mad.location.manager.lib.Services.ServicesHelper; +import mad.location.manager.lib.Services.Settings; + public class MainActivity extends AppCompatActivity implements LocationServiceInterface, MapInterface, ILogger { private SharedPreferences mSharedPref; private String xLogFolderPath; - private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - class ChangableFileNameGenerator implements FileNameGenerator { + private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + static class ChangableFileNameGenerator implements FileNameGenerator { private String fileName; public void setFileName(String fileName) { this.fileName = fileName; @@ -132,8 +132,8 @@ protected Object doInBackground(Object[] objects) { @Override protected void onProgressUpdate(Object... values) { - TextView tvStatus = (TextView) findViewById(R.id.tvStatus); - TextView tvDistance = (TextView) findViewById(R.id.tvDistance); + TextView tvStatus = findViewById(R.id.tvStatus); + TextView tvDistance = findViewById(R.id.tvDistance); if (m_isLogging) { if (m_geoHashRTFilter == null) return; @@ -178,11 +178,11 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } private void set_isLogging(boolean isLogging) { - Button btnStartStop = (Button) findViewById(R.id.btnStartStop); - TextView tvStatus = (TextView) findViewById(R.id.tvStatus); - Button btnCalibrate = (Button) findViewById(R.id.btnCalibrate); - Button gpsProvider = (Button) findViewById(R.id.button_gps); - Button fusedProvider = (Button) findViewById(R.id.button_fused); + Button btnStartStop = findViewById(R.id.btnStartStop); + TextView tvStatus = findViewById(R.id.tvStatus); + Button btnCalibrate = findViewById(R.id.btnCalibrate); + Button gpsProvider = findViewById(R.id.button_gps); + Button fusedProvider = findViewById(R.id.button_fused); String btnStartStopText; String btnTvStatusText; @@ -208,23 +208,22 @@ else if (fusedProvider.isSelected()) } value.stop(); initXlogPrintersFileName(); - Settings settings = - new Settings( - Utils.ACCELEROMETER_DEFAULT_DEVIATION, - Integer.parseInt(mSharedPref.getString("pref_gps_min_distance", "10")), - Integer.parseInt(mSharedPref.getString("pref_gps_min_time", "2000")), - Integer.parseInt(mSharedPref.getString("pref_position_min_time", "500")), - Integer.parseInt(mSharedPref.getString("pref_geohash_precision", "6")), - Integer.parseInt(mSharedPref.getString("pref_geohash_min_point", "2")), - Double.parseDouble(mSharedPref.getString("pref_sensor_frequency", "10")), - this, - true, - false, - true, - Utils.DEFAULT_VEL_FACTOR, - Utils.DEFAULT_POS_FACTOR, - finalProvider - ); + Settings settings = new Settings( + Utils.ACCELEROMETER_DEFAULT_DEVIATION, + Integer.parseInt(mSharedPref.getString("pref_gps_min_distance", "10")), + Integer.parseInt(mSharedPref.getString("pref_gps_min_time", "2000")), + Integer.parseInt(mSharedPref.getString("pref_position_min_time", "500")), + Integer.parseInt(mSharedPref.getString("pref_geohash_precision", "6")), + Integer.parseInt(mSharedPref.getString("pref_geohash_min_point", "2")), + Double.parseDouble(mSharedPref.getString("pref_sensor_frequency", "10")), + this, + true, + false, + true, + Utils.DEFAULT_VEL_FACTOR, + Utils.DEFAULT_POS_FACTOR, + finalProvider + ); value.reset(settings); //warning!! here you can adjust your filter behavior value.start(); }); @@ -251,9 +250,9 @@ else if (fusedProvider.isSelected()) } private void set_isCalibrating(boolean isCalibrating, boolean byUser) { - Button btnStartStop = (Button) findViewById(R.id.btnStartStop); - TextView tvStatus = (TextView) findViewById(R.id.tvStatus); - Button btnCalibrate = (Button) findViewById(R.id.btnCalibrate); + Button btnStartStop = findViewById(R.id.btnStartStop); + TextView tvStatus = findViewById(R.id.tvStatus); + Button btnCalibrate = findViewById(R.id.btnCalibrate); String btnCalibrateText; String tvStatusText; @@ -326,7 +325,7 @@ private void initActivity() { //uncaught exceptions private Thread.UncaughtExceptionHandler defaultUEH; // handler listener - private Thread.UncaughtExceptionHandler _unCaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { + private final Thread.UncaughtExceptionHandler _unCaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { try { @@ -354,18 +353,18 @@ public void locationChanged(Location location) { public static final int FILTER_KALMAN_ONLY = 0; public static final int FILTER_KALMAN_WITH_GEO = 1; public static final int GPS_ONLY = 2; - private int routeColors[] = {R.color.mapbox_blue, R.color.colorAccent, R.color.green}; - private int routeWidths[] = {1, 3, 1}; - private Polyline lines[] = new Polyline[3]; + private final int[] routeColors = {R.color.mapbox_blue, R.color.colorAccent, R.color.green}; + private final int[] routeWidths = {1, 3, 1}; + private final Polyline[] lines = new Polyline[3]; @Override public void showRoute(List route, int interestedRoute) { CheckBox cbGps, cbFilteredKalman, cbFilteredKalmanGeo; - cbGps = (CheckBox) findViewById(R.id.cbGPS); - cbFilteredKalman = (CheckBox) findViewById(R.id.cbFilteredKalman); - cbFilteredKalmanGeo = (CheckBox) findViewById(R.id.cbFilteredKalmanGeo); - boolean enabled[] = {cbFilteredKalman.isChecked(), cbFilteredKalmanGeo.isChecked(), cbGps.isChecked()}; + cbGps = findViewById(R.id.cbGPS); + cbFilteredKalman = findViewById(R.id.cbFilteredKalman); + cbFilteredKalmanGeo = findViewById(R.id.cbFilteredKalmanGeo); + boolean[] enabled = {cbFilteredKalman.isChecked(), cbFilteredKalmanGeo.isChecked(), cbGps.isChecked()}; if (m_map != null) { runOnUiThread(() -> m_mapView.post(() -> { @@ -409,7 +408,7 @@ public void setAllGesturesEnabled(boolean enabled) { } public void setupMap(@Nullable Bundle savedInstanceState) { - m_mapView = (MapView) findViewById(R.id.mapView); + m_mapView = findViewById(R.id.mapView); m_mapView.onCreate(savedInstanceState); m_presenter = new MapPresenter(this, this, m_geoHashRTFilter); @@ -423,23 +422,23 @@ public void setupMap(@Nullable Bundle savedInstanceState) { progress.show(); m_map.setStyleUrl(BuildConfig.lightMapStyle); - m_map.setStyleUrl(Style.SATELLITE_STREETS, new MapboxMap.OnStyleLoadedListener() { - @Override - public void onStyleLoaded(String style) { - m_map.getUiSettings().setLogoEnabled(false); - m_map.getUiSettings().setAttributionEnabled(false); - m_map.getUiSettings().setTiltGesturesEnabled(false); - - int leftMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); - int topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics()); - int rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); - int bottomMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); - m_map.getUiSettings().setCompassMargins(leftMargin, topMargin, rightMargin, bottomMargin); - ServicesHelper.addLocationServiceInterface(this_); - m_presenter.getRoute(); - progress.dismiss(); + m_map.setStyleUrl( + Style.SATELLITE_STREETS, + style -> { + m_map.getUiSettings().setLogoEnabled(false); + m_map.getUiSettings().setAttributionEnabled(false); + m_map.getUiSettings().setTiltGesturesEnabled(false); + + int leftMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); + int topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics()); + int rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); + int bottomMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); + m_map.getUiSettings().setCompassMargins(leftMargin, topMargin, rightMargin, bottomMargin); + ServicesHelper.addLocationServiceInterface(this_); + m_presenter.getRoute(); + progress.dismiss(); } - }); + ); }); } @@ -455,10 +454,10 @@ protected void onCreate(Bundle savedInstanceState) { setupMap(savedInstanceState); CheckBox cbGps, cbFilteredKalman, cbFilteredKalmanGeo; - cbGps = (CheckBox) findViewById(R.id.cbGPS); - cbFilteredKalman = (CheckBox) findViewById(R.id.cbFilteredKalman); - cbFilteredKalmanGeo = (CheckBox) findViewById(R.id.cbFilteredKalmanGeo); - CheckBox cb[] = {cbFilteredKalman, cbFilteredKalmanGeo, cbGps}; + cbGps = findViewById(R.id.cbGPS); + cbFilteredKalman = findViewById(R.id.cbFilteredKalman); + cbFilteredKalmanGeo = findViewById(R.id.cbFilteredKalmanGeo); + CheckBox[] cb = {cbFilteredKalman, cbFilteredKalmanGeo, cbGps}; for (int i = 0; i < 3; ++i) { if (cb[i] == null) continue; @@ -480,22 +479,16 @@ protected void onCreate(Bundle savedInstanceState) { } else { //todo set some status } - Button gpsProvider = (Button) findViewById(R.id.button_gps); - Button fusedProvider = (Button) findViewById(R.id.button_fused); + Button gpsProvider = findViewById(R.id.button_gps); + Button fusedProvider = findViewById(R.id.button_fused); gpsProvider.setSelected(true); - gpsProvider.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - fusedProvider.setSelected(false); - gpsProvider.setSelected(true); - } + gpsProvider.setOnClickListener(view -> { + fusedProvider.setSelected(false); + gpsProvider.setSelected(true); }); - fusedProvider.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - gpsProvider.setSelected(false); - fusedProvider.setSelected(true); - } + fusedProvider.setOnClickListener(view -> { + gpsProvider.setSelected(false); + fusedProvider.setSelected(true); }); } @@ -579,14 +572,14 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.action_settings: - Intent intent = new Intent(this, SettingsActivity.class); - startActivity(intent); - return true; + if (item.getItemId() == R.id.action_settings) { + Intent intent = new Intent( + this, + SettingsActivity.class + ); + startActivity(intent); + return true; } - return super.onOptionsItemSelected(item); } - } diff --git a/build.gradle b/build.gradle index 539f7c2..007558a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - repositories { mavenCentral() maven { url "https://maven.google.com" } google() - jcenter() - } dependencies { - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - classpath "com.android.tools.build:gradle:4.0.2" + classpath 'com.android.tools.build:gradle:7.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -26,7 +22,6 @@ allprojects { maven { url "https://maven.google.com" } - jcenter() google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ed61b3f..9a9c324 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/madlocationmanager/build.gradle b/madlocationmanager/build.gradle index 865a07d..002ed79 100644 --- a/madlocationmanager/build.gradle +++ b/madlocationmanager/build.gradle @@ -1,8 +1,6 @@ plugins { id 'com.android.library' - id 'com.github.dcendents.android-maven' id 'maven-publish' - id "com.jfrog.bintray" version "1.8.5" } group='com.github.maddevsio' @@ -13,37 +11,35 @@ ext { } android { - compileSdkVersion 30 + compileSdkVersion 32 defaultConfig { - minSdkVersion 18 - targetSdkVersion 30 - versionCode 1 - versionName "1.0" - + minSdkVersion 23 + targetSdkVersion 32 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - } - buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - + compileOptions { + targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + } + namespace 'mad.location.manager' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - api 'androidx.appcompat:appcompat:1.2.0' + api 'androidx.appcompat:appcompat:1.4.1' api 'androidx.legacy:legacy-support-v4:1.0.0' - api 'com.google.android.material:material:1.2.1' - api 'androidx.recyclerview:recyclerview:1.1.0' - implementation "com.google.android.gms:play-services-location:17.1.0" - testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + api 'com.google.android.material:material:1.6.0' + implementation 'com.google.android.gms:play-services-location:19.0.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } task sourceJar(type: Jar) { @@ -112,32 +108,3 @@ project.afterEvaluate { } } -bintray { - dryRun = false - publish = true - override = true - user = System.getenv('BINTRAY_USER') ?: (project.hasProperty('bintrayUser') ? project.property('bintrayUser') : '') - key = System.getenv('BINTRAY_KEY') ?: (project.hasProperty('bintrayKey') ? project.property('bintrayKey') : '') - publications = ['mavenPublication'] - - pkg { - repo = 'maven' - name = 'mad-location-manager' - userOrg = 'Lezh1k' - description = 'This is library for GPS and Accelerometer data "fusion" with Kalman filter' - publications = ['mavenPublication'] - licenses = ['MIT'] - vcsUrl = 'https://github.com/maddevsio/mad-location-manager.git' - websiteUrl = 'https://github.com/maddevsio/mad-location-manager.git' - issueTrackerUrl = 'https://github.com/maddevsio/mad-location-manager/issues' - githubRepo = 'maddevsio/mad-location-manager' - githubReleaseNotesFile = 'README.md' - version { - name = releaseVersion - desc = 'Mad Location Manager v' + releaseVersion - released = new Date() - vcsTag = releaseVersion - } - } -} - diff --git a/madlocationmanager/src/main/AndroidManifest.xml b/madlocationmanager/src/main/AndroidManifest.xml index c7f72ea..4e1e824 100644 --- a/madlocationmanager/src/main/AndroidManifest.xml +++ b/madlocationmanager/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - +