Skip to content

Commit

Permalink
Update to v3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Dec 1, 2024
2 parents 0d358e2 + 4432b57 commit e2f17ee
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 43 deletions.
Binary file added apk/GPSLogger-3.2.3.apk
Binary file not shown.
Binary file modified apk/GPSLogger-latest.apk
Binary file not shown.
11 changes: 5 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ apply plugin: 'com.android.application'

android {
namespace 'eu.basicairdata.graziano.gpslogger'
compileSdk 33
buildToolsVersion '33.0.1'
compileSdk 34

defaultConfig {
applicationId "eu.basicairdata.graziano.gpslogger"
minSdkVersion 14
targetSdkVersion 33
targetSdkVersion 34

// -----------------------------------------------------------------------------------------
// We use the Semantic Versioning (https://semver.org/):
versionName '3.2.2'
versionCode 51
versionName '3.2.3'
versionCode 52
// -----------------------------------------------------------------------------------------

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -76,7 +75,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.preference:preference:1.2.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="20"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import androidx.fragment.app.Fragment;

import android.os.Vibrator;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
Expand Down Expand Up @@ -90,6 +92,7 @@ public void onClick(View v) {
}
});
tvAnnotateButton = view.findViewById(R.id.id_annotate);
tvAnnotateButton.setHapticFeedbackEnabled(false);
tvAnnotateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -111,13 +114,38 @@ public boolean onLongClick(View v) {
}
});
tvRecordButton = view.findViewById(R.id.id_record);
tvRecordButton.setHapticFeedbackEnabled(false);
tvRecordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isAdded())
((GPSActivity) getActivity()).onToggleRecord();
}
});
tvRecordButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (isAdded()) {
//Log.w("myApp", "[#] FragmentRecordingControls.java - REQUEST TO ACTIVATE FORCED RECORDING OF TRACKPOINTS");
((GPSActivity) getActivity()).onRequestForceRecord();
Update();
}
return true;
}
});
tvRecordButton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
//Log.w("myApp", "[#] FragmentRecordingControls.java - (ACTION DOWN FOR FORCED RECORDING OF TRACKPOINTS)");
} else if (event.getAction() == android.view.MotionEvent.ACTION_UP || event.getAction() == android.view.MotionEvent.ACTION_CANCEL) {
Log.w("myApp", "[#] FragmentRecordingControls.java - DEACTIVATE FORCE RECORDING OF TRACKPOINTS");
gpsApp.setForcedTrackpointsRecording(false);
Update();
}
return false;
}
});
tvGeoPointsNumber = view.findViewById(R.id.id_textView_GeoPoints);
tvPlacemarksNumber = view.findViewById(R.id.id_textView_Placemarks);
return view;
Expand Down Expand Up @@ -234,7 +262,7 @@ private void setButtonToDisabledState(@NonNull TextView button, int imageId, int
public void Update() {
if (isAdded()) {
final Track track = gpsApp.getCurrentTrack();
final boolean isRec = gpsApp.isRecording();
final boolean isRec = gpsApp.isRecording() || gpsApp.isForcedTrackpointsRecording();
final boolean isAnnot = gpsApp.isPlacemarkRequested();
final boolean isLck = gpsApp.isBottomBarLocked();
if (track != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import android.Manifest;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
Expand All @@ -48,12 +50,15 @@
import androidx.preference.PreferenceManager;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;

import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

Expand Down Expand Up @@ -135,6 +140,7 @@ public void onTabSelected(TabLayout.Tab tab) {
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setHideable(false);
bottomSheet.setFocusable(false);
updateNavigationBarColor(getWindow(),getApplicationContext());
}

@Override
Expand Down Expand Up @@ -818,6 +824,25 @@ public void onRequestAnnotation() {
}
}

/**
* Process the request to to force recording the current trackpoint. It manages the button behaviour and
* the status of the request.
* It also displays some toasts to inform the user about some conditions.
*/
public void onRequestForceRecord() {
if (!gpsApp.isBottomBarLocked()) {
//Log.w("myApp", "[#] GPSActivity.java - ACTIVATE FORCED RECORDING OF TRACKPOINTS");
gpsApp.setForcedTrackpointsRecording(true);
//Update();
} else {
//Log.w("myApp", "[#] GPSActivity.java - FORCED RECORDING OF TRACKPOINTS NOT POSSIBLE, BOTTOM BAR LOCKED");
if (toast != null) toast.cancel();
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
toast.show();
}
}

/**
* Manages the Lock button behaviour.
*/
Expand All @@ -831,4 +856,21 @@ public void onToggleLock() {
}
//Update();
}

/**
* Updates the navigation bar background and icon colors to match the bottom bar background based on the theme.
*/
public void updateNavigationBarColor(Window window, Context applicationContext) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (window != null && applicationContext instanceof Application) {
// Retrieve the preferred color theme from shared preferences and check if it's "1"
if (TextUtils.equals("1", PreferenceManager.getDefaultSharedPreferences(applicationContext).getString("prefColorTheme", "2"))) {
window.setNavigationBarColor(getResources().getColor(R.color.colorRecControlBackground,getTheme()));
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
} else {
window.setNavigationBarColor(getResources().getColor(R.color.colorRecControlBackground,getTheme()));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import androidx.documentfile.provider.DocumentFile;
import androidx.preference.PreferenceManager;

import android.os.Vibrator;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
Expand Down Expand Up @@ -197,6 +198,7 @@ public class GPSApplication extends Application implements LocationListener {
private boolean isRecording; // True if the recording is active
private boolean isBottomBarLocked; // True if the bottom bar is locked
private boolean isGPSLocationUpdatesActive; // True if the Location Manager is active (is requesting FIXes)
private boolean isForcedTrackpointsRecording = false; // if True, the current fix is recorded into the track;
private int gpsStatus = GPS_SEARCHING; // The status of the GPS: GPS_DISABLED, GPS_OUTOFSERVICE,
// GPS_TEMPORARYUNAVAILABLE, GPS_SEARCHING, GPS_STABILIZING;
private LocationManager locationManager = null; // GPS LocationManager
Expand Down Expand Up @@ -453,13 +455,18 @@ public void onServiceDisconnected(ComponentName arg0) {
/**
* Starts and Binds to the Foreground Service GPSService
*/
private void startAndBindGPSService() {
gpsServiceIntent = new Intent(GPSApplication.this, GPSService.class);
//Start the service
startService(gpsServiceIntent);
//Bind to the service
bindService(gpsServiceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
Log.w("myApp", "[#] GPSApplication.java - StartAndBindGPSService");
public void startAndBindGPSService() {
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) &&
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)) {
gpsServiceIntent = new Intent(GPSApplication.this, GPSService.class);
//Start the service
startService(gpsServiceIntent);
//Bind to the service
bindService(gpsServiceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
Log.w("myApp", "[#] GPSApplication.java - StartAndBindGPSService - SERVICE STARTED");
} else {
Log.w("myApp", "[#] GPSApplication.java - StartAndBindGPSService - UNABLE TO START THE SERVICE");
}
}

/**
Expand Down Expand Up @@ -690,6 +697,14 @@ public void setCurrentTrackVisible(boolean currentTrackVisible) {
isCurrentTrackVisible = currentTrackVisible;
}

public boolean isForcedTrackpointsRecording() {
return isForcedTrackpointsRecording;
}

public void setForcedTrackpointsRecording(boolean forcedTrackpointsRecording) {
isForcedTrackpointsRecording = forcedTrackpointsRecording;
}

public boolean isBackgroundActivityRestricted() {
return isBackgroundActivityRestricted;
}
Expand Down Expand Up @@ -1183,7 +1198,7 @@ public void onLocationChanged(@NonNull Location loc) {

// Distance Filter and Interval Filter in OR
// The Trackpoint is recorded when at less one filter is True.
if ((isRecording) && ((prevRecordedFix == null)
if ((isRecording && ((prevRecordedFix == null)
|| (forceRecord) // Forced to record the point
|| ((prefGPSinterval == 0) && (prefGPSdistance == 0)) // No filters enabled --> it records all the points
|| ((prefGPSinterval > 0)
Expand All @@ -1196,7 +1211,14 @@ public void onLocationChanged(@NonNull Location loc) {
|| ((prefGPSinterval == 0)
&& (prefGPSdistance > 0) // Only distance filter enabled
&& ((loc.distanceTo(prevRecordedFix.getLocation()) >= prefGPSdistance)))
|| (currentTrack.getNumberOfLocations() == 0))){ // It is the first point of a track
|| (currentTrack.getNumberOfLocations() == 0))) // It is the first point of a track
|| (isForcedTrackpointsRecording)){ // recording button is long pressed

if (isForcedTrackpointsRecording) {
Vibrator vibrator;
vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(150);
}

prevRecordedFix = eloc;
ast.taskType = TASK_ADDLOCATION;
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_gps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@

</androidx.core.widget.NestedScrollView>

<androidx.appcompat.widget.AppCompatImageView
android:src="@drawable/shadow"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="5dp"
/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Loading

0 comments on commit e2f17ee

Please sign in to comment.