diff --git a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertArrayAdapter.java b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertArrayAdapter.java index 89a84235..39963a55 100644 --- a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertArrayAdapter.java +++ b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertArrayAdapter.java @@ -5,6 +5,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -30,6 +31,8 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.alert_log_item, parent, false); } + ImageView playIcon = convertView.findViewById(R.id.alert_log_item_image_play); + playIcon.setVisibility(alert.isClosed() ? View.INVISIBLE : View.VISIBLE); TextView timeWindow = convertView.findViewById(R.id.alert_log_item_time_window); TextView durations = convertView.findViewById(R.id.alert_log_item_durations); timeWindow.setText(AlertViewHelper.getTimeWindow(alert)); diff --git a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertDetailActivity.java b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertDetailActivity.java index 5efce86b..7fb22feb 100644 --- a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertDetailActivity.java +++ b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertDetailActivity.java @@ -4,6 +4,7 @@ import android.view.MenuItem; import android.view.View; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -41,6 +42,10 @@ protected void onCreate(Bundle savedInstanceState) { ArrayAdapter adapter = new AlertCallArrayAdapter(this, alert.getCalls()); View headerView = getLayoutInflater().inflate(R.layout.activity_alert_detail_header, listView, false); + + ImageView playIcon = headerView.findViewById(R.id.alert_detail_header_image_play); + playIcon.setVisibility(alert.isClosed() ? View.INVISIBLE : View.VISIBLE); + TextView timeWindow = headerView.findViewById(R.id.alert_detail_header_time_window); TextView currentState = headerView.findViewById(R.id.alert_detail_header_current_state); TextView durations = headerView.findViewById(R.id.alert_detail_header_durations); diff --git a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertViewHelper.java b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertViewHelper.java index 9f76f453..bd505eeb 100644 --- a/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertViewHelper.java +++ b/app/src/main/java/com/github/frimtec/android/pikettassist/ui/alerts/AlertViewHelper.java @@ -38,11 +38,8 @@ static String getDurations(Context context, Alert alert) { Duration confirmDuration = alert.getConfirmTime() != null ? Duration.between(alert.getStartTime(), alert.getConfirmTime()) : Duration.ofSeconds(0); confirmText = String.format(context.getString(R.string.alert_view_confirm_time), confirmDuration.getSeconds()); } - String durationText = ""; - if (alert.isClosed()) { - Duration duration = Duration.between(alert.getStartTime(), alert.getEndTime()); - durationText = String.format(context.getString(R.string.alert_view_duration), duration.getSeconds() / 60d); - } + Duration duration = Duration.between(alert.getStartTime(), alert.isClosed() ? alert.getEndTime() : Instant.now()); + String durationText = String.format(context.getString(R.string.alert_view_duration), duration.getSeconds() / 60d); return Stream.of(confirmText, durationText).filter(((Predicate) String::isEmpty).negate()).collect(Collectors.joining("\n")); } diff --git a/app/src/main/res/drawable/ic_event.xml b/app/src/main/res/drawable/ic_event.xml index cfeb149c..a179fe22 100644 --- a/app/src/main/res/drawable/ic_event.xml +++ b/app/src/main/res/drawable/ic_event.xml @@ -4,15 +4,15 @@ android:viewportWidth="612" android:viewportHeight="612"> diff --git a/app/src/main/res/drawable/ic_play_arrow_24dp.xml b/app/src/main/res/drawable/ic_play_arrow_24dp.xml index a24a5fc2..230f7cb9 100644 --- a/app/src/main/res/drawable/ic_play_arrow_24dp.xml +++ b/app/src/main/res/drawable/ic_play_arrow_24dp.xml @@ -1,5 +1,5 @@ - - + diff --git a/app/src/main/res/layout/activity_alert_detail_header.xml b/app/src/main/res/layout/activity_alert_detail_header.xml index edb27d9e..e419c2d5 100644 --- a/app/src/main/res/layout/activity_alert_detail_header.xml +++ b/app/src/main/res/layout/activity_alert_detail_header.xml @@ -17,6 +17,16 @@ android:layout_marginRight="5dp" android:layout_marginBottom="5dp" app:srcCompat="@drawable/ic_siren" /> + +