Accuracy level indicator restyling

This commit is contained in:
Daniele Verducci (Slimpenguin)
2022-01-15 10:01:51 +01:00
parent 907fcb4cb1
commit 864802cdae
7 changed files with 65 additions and 15 deletions

View File

@ -369,13 +369,12 @@ public class GeofavoriteDetailActivity extends AppCompatActivity implements Loca
}
public void setAccuracy(float accuracy) {
// Display accuracy in meters
binding.accuracyTv.setText(getString(R.string.accuracy).replace("{accuracy}", ((int)accuracy) + ""));
// Color the accuracy background with a scale from red (MINIMUM_ACCEPTABLE_ACCURACY) to green (0 meters)
float red = accuracy / MINIMUM_ACCEPTABLE_ACCURACY;
if (red > 1.0f) red = 1.0f;
float green = 1.0f - red;
if (Build.VERSION.SDK_INT >= 26)
binding.accuracyTv.setBackgroundColor(Color.rgb(red, green, 0.0f));
// Display accuracy in progress bar
int accuracyPercent = (int)accuracy > 100 ? 0 : Math.abs((int)accuracy - 100);
binding.accuracyProgress.setIndeterminate(false);
binding.accuracyProgress.setProgress(accuracyPercent);
}
public void setCategories(HashSet<String> categories) {