Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies and so #118

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lezh1k.sensordatacollector">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -19,7 +18,8 @@
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,22 +24,19 @@
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;
import com.elvishew.xlog.printer.Printer;
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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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();
});
Expand All @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<LatLng> 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(() -> {
Expand Down Expand Up @@ -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);
Expand All @@ -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();
}
});
);
});
}

Expand All @@ -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;
Expand All @@ -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);
});
}

Expand Down Expand Up @@ -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);
}

}
7 changes: 1 addition & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,7 +22,6 @@ allprojects {
maven {
url "https://maven.google.com"
}
jcenter()
google()
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading