Skip to content

Commit

Permalink
#172 Small UI improvements in alert log tab
Browse files Browse the repository at this point in the history
  • Loading branch information
frimtec committed Aug 28, 2020
1 parent 2671ace commit 0e89312
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -41,6 +42,10 @@ protected void onCreate(Bundle savedInstanceState) {
ArrayAdapter<AlertCall> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>) String::isEmpty).negate()).collect(Collectors.joining("\n"));
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/ic_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
android:viewportWidth="612"
android:viewportHeight="612">
<path
android:fillColor="#FF888888"
android:fillColor="#FF000000"
android:pathData="M233.667,58.286l-0.146,29.143l143.004,0l0.175,-29.143z" />
<path
android:fillColor="#FF888888"
android:fillColor="#FF000000"
android:pathData="M466.286,87.458V29.114C466.286,13.027 453.2,0 437.143,0C421.056,0 408,13.027 408,29.114v58.344c0,16.087 13.085,29.114 29.143,29.114C453.229,116.571 466.286,103.544 466.286,87.458z" />
<path
android:fillColor="#FF888888"
android:fillColor="#FF000000"
android:pathData="M182.143,116.571c12.065,0 21.857,-9.733 21.857,-21.915V21.916C204,9.821 194.237,0 182.143,0h-14.572c-12.065,0 -21.857,9.734 -21.857,21.916v72.711c0,12.124 9.763,21.944 21.857,21.944H182.143z" />
<path
android:fillColor="#FF888888"
android:fillColor="#FF000000"
android:pathData="M115.697,87.429l0.146,-29.143H18.331C8.189,58.286 0,66.766 0,77.199v515.916C0,603.549 8.189,612 18.302,612h575.367c10.142,0 18.331,-8.48 18.331,-18.885V77.199c0,-10.462 -8.219,-18.914 -18.331,-18.914h-98.036l-0.146,29.143h87.37v145.714H29.143V87.429H115.697zM116.571,582.857H41.674c-6.936,0 -12.531,-4.867 -12.531,-10.899v-76.529h87.428V582.857zM116.571,466.286H29.143v-87.429h87.428V466.286zM495.429,262.286h87.429v87.428h-87.429V262.286zM495.429,378.857h87.429v87.429h-87.429V378.857zM495.429,495.429h87.429v76.529c0,6.003 -5.625,10.899 -12.531,10.899h-74.897V495.429zM378.857,262.286h87.429v87.428h-87.429V262.286zM378.857,378.857h87.429v87.429h-87.429V378.857zM378.857,495.429h87.429v87.429h-87.429V495.429zM262.286,262.286h87.428v87.428h-87.428V262.286zM262.286,495.429h87.428v87.429h-87.428V495.429zM145.714,262.286h87.429v87.428h-87.429V262.286zM145.714,378.857h87.429v87.429h-87.429V378.857zM145.714,495.429h87.429v87.429h-87.429V495.429zM116.571,262.286v87.428H29.143v-87.428H116.571z" />
</vector>
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_play_arrow_24dp.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<vector android:height="24dp" android:tint="@color/colorPrimary"
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M8,5v14l11,-7z"/>
<path android:strokeColor="@color/black" android:strokeWidth="0.5" android:fillAlpha="0.9" android:fillColor="@color/colorPrimary" android:pathData="M8,5v14l11,-7z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_alert_detail_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
app:srcCompat="@drawable/ic_siren" />
<ImageView
android:id="@+id/alert_detail_header_image_play"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
app:srcCompat="@drawable/ic_play_arrow_24dp" />

<TableLayout
android:layout_width="wrap_content"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/alert_log_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
app:srcCompat="@drawable/ic_siren" />
<ImageView
android:id="@+id/alert_log_item_image_play"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="5dp"
app:srcCompat="@drawable/ic_play_arrow_24dp" />

<TextView
android:id="@+id/alert_log_item_time_window"
Expand Down

0 comments on commit 0e89312

Please sign in to comment.