Skip to content

Commit

Permalink
Using @string for Toast in TrackDetail and TrackManager
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonials authored and Binnette committed Dec 12, 2024
1 parent fdf0a8b commit 76f5100
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/net/osmtracker/activity/TrackDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ else if (ContextCompat.checkSelfPermission(this,
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
new AlertDialog.Builder(this)
.setTitle("Permission required")
.setMessage("To export the GPX trace we need to write on the storage.")
.setPositiveButton("Accept", (dialog, which) -> {
.setTitle(R.string.permission_required)
.setMessage(R.string.storage_permission_for_export_GPX)
.setPositiveButton(R.string.acccept, (dialog, which) -> {
// Request the permission again
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
RC_WRITE_PERMISSIONS);
})
.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss())
.setNegativeButton(R.string.menu_cancel, (dialog, which) -> dialog.dismiss())
.show();
} else {
// No explanation needed, we can request the permission.
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/net/osmtracker/activity/TrackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private void tryStartTrackLogger(Intent intent){
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
Log.i(TAG,"Should explain");
Toast.makeText(this, "Can't continue without GPS permission",
Toast.makeText(this, R.string.gps_perms_required,
Toast.LENGTH_LONG).show();
}

Expand Down Expand Up @@ -729,7 +729,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[],
// functionality that depends on this permission.
//TODO: add an informative message.
Log.w(TAG, "we should explain why we need write permission_EXPORT_ALL");
Toast.makeText(this, "To export the GPX trace we need to write on the storage.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.storage_permission_for_export_GPX, Toast.LENGTH_LONG).show();
}
break;
}
Expand All @@ -747,7 +747,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[],
// functionality that depends on this permission.
//TODO: add an informative message.
Log.w(TAG, "we should explain why we need write permission_EXPORT_ONE");
Toast.makeText(this, "To export the GPX trace we need to write on the storage.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.storage_permission_for_export_GPX, Toast.LENGTH_LONG).show();
}
break;
}
Expand All @@ -764,7 +764,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[],
// functionality that depends on this permission.
//TODO: add an informative message.
Log.w(TAG, "Permission not granted");
Toast.makeText(this, "To display the track properly we need access to the storage.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.storage_permission_for_display_track, Toast.LENGTH_LONG).show();
}
break;
}
Expand All @@ -782,7 +782,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[],
// functionality that depends on this permission.
//TODO: add an informative message.
Log.w(TAG, "Permission not granted");
Toast.makeText(this, "To share the track properly we need access to the storage.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.storage_permission_for_share_track, Toast.LENGTH_LONG).show();
}
break;
}
Expand All @@ -799,7 +799,7 @@ public void onRequestPermissionsResult(int requestCode, String permissions[],
// functionality that depends on this permission.
//TODO: add an informative message.
Log.w(TAG, "Permission not granted");
Toast.makeText(this, "To upload the track to OSM we need access to the storage.", Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.storage_permission_for_upload_to_OSM, Toast.LENGTH_LONG).show();
}
break;
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@
<string name="error_voicerec_failed">Voice recording has failed</string>
<string name="error_userlayout_parsing">Error while parsing XML layout file. Please revert to default layout.</string>

<!-- messages -->
<string name="permission_required">Permission required</string>
<string name="storage_permission_for_export_GPX">To export the GPX trace we need to write on the storage.</string>
<string name="storage_permission_for_display_track">To display the track properly we need access to the storage.</string>
<string name="storage_permission_for_share_track">To share the track properly we need access to the storage.</string>
<string name="storage_permission_for_upload_to_OSM">To upload the track to OSM we need access to the storage.</string>
<string name="acccept">Accept</string>
<string name="gps_perms_required">Can\'t continue without GPS permission</string>

<!-- GPX -->
<string name="gpx_track_name">Tracked with OSMTracker for Android™</string>
<string name="gpx_hdop_approximation_cmt">Warning: HDOP values aren\'t the HDOP as returned by the GPS device. They\'re approximated from the location accuracy in meters.</string>
Expand Down

0 comments on commit 76f5100

Please sign in to comment.