Skip to content

Commit 7bf54a5

Browse files
Update to v3.1.4
2 parents 3f2b789 + 10601e6 commit 7bf54a5

25 files changed

+796
-302
lines changed

apk/GPSLogger-3.1.4.apk

4.96 MB
Binary file not shown.

apk/GPSLogger-latest.apk

1.26 MB
Binary file not shown.

app/build.gradle

+14-19
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,19 @@
2222
apply plugin: 'com.android.application'
2323

2424
android {
25-
compileSdkVersion 30
26-
buildToolsVersion '30.0.3'
27-
28-
lintOptions {
29-
//checkReleaseBuilds false
30-
// Or, if you prefer, you can continue to check for errors in release builds,
31-
// but continue the build even when errors are found:
32-
abortOnError false
33-
}
25+
compileSdkVersion 32
26+
buildToolsVersion '32.0.0'
3427

35-
aaptOptions {
36-
// Disable PNG Crunching
37-
cruncherEnabled = false
38-
}
3928

4029
defaultConfig {
4130
applicationId "eu.basicairdata.graziano.gpslogger"
4231
minSdkVersion 14
43-
targetSdkVersion 30
32+
targetSdkVersion 32
4433

4534
// -----------------------------------------------------------------------------------------
4635
// We use the Semantic Versioning (https://semver.org/):
47-
versionName '3.1.3'
48-
versionCode 44
36+
versionName '3.1.4'
37+
versionCode 45
4938
// -----------------------------------------------------------------------------------------
5039

5140
vectorDrawables.useSupportLibrary = true
@@ -60,6 +49,7 @@ android {
6049
buildTypes {
6150
debug {
6251
minifyEnabled false
52+
crunchPngs false
6353
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
6454
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
6555

@@ -68,21 +58,26 @@ android {
6858
}
6959
release {
7060
minifyEnabled false
61+
crunchPngs false
7162
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7263
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
7364
}
7465
}
66+
67+
lint {
68+
abortOnError false
69+
}
7570
}
7671

7772
dependencies {
7873
implementation fileTree(dir: 'libs', include: ['*.jar'])
7974
testImplementation 'junit:junit:4.13.2'
8075

81-
implementation 'androidx.appcompat:appcompat:1.3.1'
76+
implementation 'androidx.appcompat:appcompat:1.4.1'
8277
implementation 'androidx.cardview:cardview:1.0.0'
8378
implementation 'androidx.recyclerview:recyclerview:1.2.1'
84-
implementation 'androidx.preference:preference:1.1.1'
85-
implementation 'com.google.android.material:material:1.4.0'
79+
implementation 'androidx.preference:preference:1.2.0'
80+
implementation 'com.google.android.material:material:1.5.0'
8681

8782
implementation 'com.github.bumptech.glide:glide:3.8.0'
8883

app/src/main/AndroidManifest.xml

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2525
package="eu.basicairdata.graziano.gpslogger">
2626

27+
<uses-permission android:name="android.permission.VIBRATE" />
28+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2729
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2830
<uses-permission android:name="android.permission.INTERNET" />
2931
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@@ -59,7 +61,6 @@
5961
android:supportsRtl="true">
6062

6163
<activity android:name=".GPSActivity"
62-
android:label="@string/app_name"
6364
android:exported="true"
6465
android:launchMode="singleTask"
6566
android:windowSoftInputMode="adjustPan" >
@@ -90,7 +91,8 @@
9091
android:resource="@xml/filepaths" />
9192
</provider>
9293

93-
<receiver android:name=".ActionsBroadcastReceiver">
94+
<receiver android:name=".ActionsBroadcastReceiver"
95+
android:exported="false">
9496
<intent-filter>
9597
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
9698
</intent-filter>

app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentGPSFix.java

+52
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package eu.basicairdata.graziano.gpslogger;
2424

25+
import static android.content.Context.POWER_SERVICE;
26+
2527
import android.Manifest;
2628
import android.content.Intent;
2729
import android.content.pm.PackageManager;
@@ -32,12 +34,16 @@
3234
import androidx.cardview.widget.CardView;
3335
import androidx.core.content.ContextCompat;
3436
import androidx.fragment.app.Fragment;
37+
38+
import android.os.PowerManager;
3539
import android.provider.Settings;
3640
import android.view.LayoutInflater;
3741
import android.view.View;
3842
import android.view.ViewGroup;
3943
import android.view.ViewTreeObserver;
4044
import android.widget.FrameLayout;
45+
import android.widget.ImageButton;
46+
import android.widget.ImageView;
4147
import android.widget.LinearLayout;
4248
import android.widget.TableLayout;
4349
import android.widget.TextView;
@@ -93,7 +99,9 @@ public class FragmentGPSFix extends Fragment {
9399
private CardView cvWarningLocationDenied;
94100
private CardView cvWarningGPSDisabled;
95101
private CardView cvWarningBackgroundRestricted;
102+
private CardView cvWarningBatteryOptimised;
96103
private LinearLayout llTimeSatellites;
104+
private ImageView iwWarningBatteryOptimisedClose;
97105

98106
private PhysicalData phdLatitude;
99107
private PhysicalData phdLongitude;
@@ -110,6 +118,7 @@ public class FragmentGPSFix extends Fragment {
110118
private boolean EGMAltitudeCorrection;
111119
private boolean isValidAltitude;
112120
private boolean isBackgroundActivityRestricted;
121+
private PowerManager powerManager;
113122

114123
/**
115124
* The Observer that calculate the new available height when the layout is changed.
@@ -185,6 +194,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
185194
cvWarningLocationDenied = view.findViewById(R.id.card_view_warning_location_denied);
186195
cvWarningGPSDisabled = view.findViewById(R.id.card_view_warning_enable_location_service);
187196
cvWarningBackgroundRestricted = view.findViewById(R.id.card_view_warning_background_restricted);
197+
cvWarningBatteryOptimised = view.findViewById(R.id.card_view_warning_battery_optimised);
188198

189199
// TableLayouts
190200
tlCoordinates = view.findViewById(R.id.id_TableLayout_Coordinates) ;
@@ -195,9 +205,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
195205
tlTime = view.findViewById(R.id.id_TableLayout_Time);
196206
tlSatellites = view.findViewById(R.id.id_TableLayout_Satellites);
197207

208+
// ImageViews
209+
210+
iwWarningBatteryOptimisedClose = view.findViewById(R.id.id_warning_battery_optimised_close);
211+
198212
// LinearLayouts
199213
llTimeSatellites = view.findViewById(R.id.id_linearLayout_Time_Satellites);
200214

215+
powerManager = (PowerManager) gpsApp.getSystemService(POWER_SERVICE);
216+
201217
cvWarningGPSDisabled.setOnClickListener(new View.OnClickListener() {
202218
@Override
203219
public void onClick(View v) {
@@ -215,6 +231,14 @@ public void onClick(View v) {
215231
}
216232
});
217233

234+
iwWarningBatteryOptimisedClose.setOnClickListener(new View.OnClickListener() {
235+
@Override
236+
public void onClick(View v) {
237+
gpsApp.setBatteryOptimisedWarningVisible(false);
238+
update();
239+
}
240+
});
241+
218242
cvWarningBackgroundRestricted.setOnClickListener(new View.OnClickListener() {
219243
@Override
220244
public void onClick(View v) {
@@ -235,6 +259,25 @@ public void onClick(View v) {
235259
}
236260
});
237261

262+
cvWarningBatteryOptimised.setOnClickListener(new View.OnClickListener() {
263+
@Override
264+
public void onClick(View v) {
265+
if (!isAWarningClicked && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)) {
266+
isAWarningClicked = true;
267+
// Go to Settings screen
268+
Intent intent = new Intent();
269+
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
270+
271+
try {
272+
getContext().startActivity(intent);
273+
} catch (Exception e) {
274+
isAWarningClicked = false;
275+
// Unable to open Intent
276+
}
277+
}
278+
}
279+
});
280+
238281
cvWarningLocationDenied.setOnClickListener(new View.OnClickListener() {
239282
@Override
240283
public void onClick(View v) {
@@ -351,6 +394,7 @@ public void update() {
351394

352395
tvGPSFixStatus.setVisibility(View.INVISIBLE);
353396
cvWarningBackgroundRestricted.setVisibility(View.GONE);
397+
cvWarningBatteryOptimised.setVisibility(View.GONE);
354398
cvWarningGPSDisabled.setVisibility(View.GONE);
355399
cvWarningLocationDenied.setVisibility(View.GONE);
356400
} else {
@@ -394,6 +438,14 @@ public void update() {
394438
cvWarningBackgroundRestricted.setVisibility(View.GONE);
395439
}
396440

441+
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
442+
&& !powerManager.isIgnoringBatteryOptimizations(gpsApp.getPackageName())
443+
&& gpsApp.isBatteryOptimisedWarningVisible()) {
444+
cvWarningBatteryOptimised.setVisibility(View.VISIBLE);
445+
} else {
446+
cvWarningBatteryOptimised.setVisibility(View.GONE);
447+
}
448+
397449
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
398450
tvGPSFixStatus.setText(R.string.gps_not_accessible);
399451
cvWarningLocationDenied.setVisibility(View.VISIBLE);

0 commit comments

Comments
 (0)