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) { public void setAccuracy(float accuracy) {
// Display accuracy in meters
binding.accuracyTv.setText(getString(R.string.accuracy).replace("{accuracy}", ((int)accuracy) + "")); 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) // Display accuracy in progress bar
float red = accuracy / MINIMUM_ACCEPTABLE_ACCURACY; int accuracyPercent = (int)accuracy > 100 ? 0 : Math.abs((int)accuracy - 100);
if (red > 1.0f) red = 1.0f; binding.accuracyProgress.setIndeterminate(false);
float green = 1.0f - red; binding.accuracyProgress.setProgress(accuracyPercent);
if (Build.VERSION.SDK_INT >= 26)
binding.accuracyTv.setBackgroundColor(Color.rgb(red, green, 0.0f));
} }
public void setCategories(HashSet<String> categories) { public void setCategories(HashSet<String> categories) {

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06c-1.13,0.12 -2.19,0.46 -3.16,0.97l1.5,1.5C10.16,5.19 11.06,5 12,5c3.87,0 7,3.13 7,7 0,0.94 -0.19,1.84 -0.52,2.65l1.5,1.5c0.5,-0.96 0.84,-2.02 0.97,-3.15L23,13v-2h-2.06zM3,4.27l2.04,2.04C3.97,7.62 3.25,9.23 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c1.77,-0.2 3.38,-0.91 4.69,-1.98L19.73,21 21,19.73 4.27,3 3,4.27zM16.27,17.54C15.09,18.45 13.61,19 12,19c-3.87,0 -7,-3.13 -7,-7 0,-1.61 0.55,-3.09 1.46,-4.27l9.81,9.81z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94L23,13v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
</vector>

View File

@ -89,15 +89,42 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="20dp"> android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="@drawable/ic_accuracy_fail"
app:tint="@color/disabled"/>
<ProgressBar
android:id="@+id/accuracy_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:indeterminate="true"
style="@style/Widget.AppCompat.ProgressBar.Horizontal" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="@drawable/ic_accuracy_ok"/>
</LinearLayout>
<TextView <TextView
android:id="@+id/accuracy_tv" android:id="@+id/accuracy_tv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginBottom="20dp"
android:textAlignment="center" android:textAlignment="center"
android:text="@string/accuracy" android:text="@string/accuracy_nosignal"
android:textColor="@android:color/white" android:textColor="@color/defaultBrand"/>
android:background="@android:color/darker_gray"/>
<LinearLayout <LinearLayout
android:id="@+id/action_icons" android:id="@+id/action_icons"
@ -112,7 +139,7 @@
android:layout_weight="1" android:layout_weight="1"
android:padding="10dp" android:padding="10dp"
android:src="@drawable/ic_share" android:src="@drawable/ic_share"
android:tint="@color/defaultBrand"/> app:tint="@color/defaultBrand"/>
<ImageView <ImageView
android:id="@+id/action_icon_nav" android:id="@+id/action_icon_nav"
@ -121,7 +148,7 @@
android:layout_weight="1" android:layout_weight="1"
android:padding="10dp" android:padding="10dp"
android:src="@drawable/ic_nav" android:src="@drawable/ic_nav"
android:tint="@color/defaultBrand"/> app:tint="@color/defaultBrand"/>
<ImageView <ImageView
android:id="@+id/action_icon_delete" android:id="@+id/action_icon_delete"
@ -130,7 +157,7 @@
android:layout_weight="1" android:layout_weight="1"
android:padding="10dp" android:padding="10dp"
android:src="@drawable/ic_delete_grey" android:src="@drawable/ic_delete_grey"
android:tint="@color/defaultBrand" app:tint="@color/defaultBrand"
android:visibility="gone"/> <!-- TODO Implement delete --> android:visibility="gone"/> <!-- TODO Implement delete -->

View File

@ -56,6 +56,7 @@
<string name="category">Categoria</string> <string name="category">Categoria</string>
<string name="coords">Coordinate</string> <string name="coords">Coordinate</string>
<string name="accuracy">Accuratezza: {accuracy} m</string> <string name="accuracy">Accuratezza: {accuracy} m</string>
<string name="accuracy_nosignal">Nessun segnale GPS!</string>
<string name="location_permission_required">Per creare un geosegnalibro è necessario consentire l\'accesso alla posizione.</string> <string name="location_permission_required">Per creare un geosegnalibro è necessario consentire l\'accesso alla posizione.</string>
<string name="confirm">Salva</string> <string name="confirm">Salva</string>
<string name="error_saving_geofavorite">Impossibile salvare il geosegnalibro</string> <string name="error_saving_geofavorite">Impossibile salvare il geosegnalibro</string>

View File

@ -25,14 +25,16 @@
<color name="defaultBrandAlpha">#550082C9</color> <color name="defaultBrandAlpha">#550082C9</color>
<color name="appbar">@android:color/white</color> <color name="appbar">@android:color/white</color>
<color name="defaultTint">#202124</color> <color name="defaultTint">#202124</color>
<color name="disabled">#666666</color>
<!-- List Colors --> <!-- List Colors -->
<color name="text_color">#333333</color> <color name="text_color">#333333</color>
<color name="secondary_text_color">#666666</color> <color name="secondary_text_color">@color/disabled</color>
<!-- Selectors text/tint colors --> <!-- Selectors text/tint colors -->
<color name="selector_item_selected">@color/defaultBrand</color> <color name="selector_item_selected">@color/defaultBrand</color>
<color name="selector_item_unselected">#666666</color> <color name="selector_item_unselected">@color/disabled</color>
<!-- Generic Colors --> <!-- Generic Colors -->
<color name="white">#fff</color> <color name="white">#fff</color>

View File

@ -55,6 +55,7 @@
<string name="category">Category</string> <string name="category">Category</string>
<string name="coords">Coordinates</string> <string name="coords">Coordinates</string>
<string name="accuracy">Accuracy: {accuracy} m</string> <string name="accuracy">Accuracy: {accuracy} m</string>
<string name="accuracy_nosignal">No GPS signal!</string>
<string name="location_permission_required">Location permission is required to create a geofavorite.</string> <string name="location_permission_required">Location permission is required to create a geofavorite.</string>
<string name="confirm">Save</string> <string name="confirm">Save</string>
<string name="error_saving_geofavorite">Unable to save geofavorite</string> <string name="error_saving_geofavorite">Unable to save geofavorite</string>