Skip to content

Commit

Permalink
Fix #380 - Show error message if user enabled logging but denied perm…
Browse files Browse the repository at this point in the history
…ission
  • Loading branch information
barbeau committed Feb 26, 2020
1 parent 1d6f073 commit b1024c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
31 changes: 19 additions & 12 deletions GPSTest/src/main/java/com/android/gpstest/util/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;

import java.io.File;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -614,27 +615,34 @@ public static Dialog createShareDialog(AppCompatActivity activity, final Locatio
}
});

if (loggingEnabled) {
// Hide the logging instructions
final File file = fileLogger.getFile();

if (loggingEnabled && file != null) {
// Hide the logging instructions - logging is enabled and working
logInstructions.setVisibility(View.GONE);
} else {
// Hide the logging and file views
// Hide the logging and file views so the user can see the instructions
fileName.setVisibility(View.GONE);
logBrowse.setVisibility(View.GONE);
logShare.setVisibility(View.GONE);
}

// Set the log file name
if (loggingEnabled) {
if (alternateFileUri == null) {
// Set the log file currently being logged to by the FileLogger
fileName.setText(fileLogger.getFile().getName());
if (file != null) {
if (alternateFileUri == null) {
// Set the log file currently being logged to by the FileLogger
fileName.setText(file.getName());
} else {
// Set the log file selected by the user using the File Browse button
String lastPathSegment = alternateFileUri.getLastPathSegment();
// Parse file name from string like "primary:gnss_log/gnss_log_2019..."
String[] parts = lastPathSegment.split("/");
fileName.setText(parts[1]);
}
} else {
// Set the log file selected by the user using the File Browse button
String lastPathSegment = alternateFileUri.getLastPathSegment();
// Parse file name from string like "primary:gnss_log/gnss_log_2019..."
String[] parts = lastPathSegment.split("/");
fileName.setText(parts[1]);
// Something went wrong - did user allow file/storage permissions when prompted when they enabled logging in Settings?
logInstructions.setText(R.string.log_error);
}
}

Expand All @@ -656,7 +664,6 @@ public static Dialog createShareDialog(AppCompatActivity activity, final Locatio
} else {
// Send the log file selected by the user using the File Browse button
IOUtils.sendLogFile(activity, alternateFileUri);

}
});

Expand Down
1 change: 1 addition & 0 deletions GPSTest/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<string name="copied_to_clipboard">Location copied to clipboard</string>
<string name="send_log">"Send log…"</string>
<string name="log_instructions">Enable logging for NMEA, raw measurements, navigation messages, and more in Settings</string>
<string name="log_error">Something went wrong with file logging. Did you allow file/storage permissions? Try re-enabling a file logging option in Settings and tap "Allow" when prompted.</string>
<string name="no_location">Try sharing your location after getting a GNSS fix</string>
<string name="include_altitude">Include altitude</string>
<string name="set_fix_frequency">Set Fix Frequency</string>
Expand Down

0 comments on commit b1024c2

Please sign in to comment.