Skip to content

Commit

Permalink
Allow colon for estimated time of log reports
Browse files Browse the repository at this point in the history
  • Loading branch information
bpross-52n committed Jul 15, 2020
1 parent 0e93f2b commit f7a98c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion org.envirocar.app/res/layout/send_log_layout_new.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
android:layout_height="wrap_content"
android:gravity="start|top"
android:imeOptions="actionNext"
android:inputType="number"
android:inputType="date|time"
android:padding="12dp" />

</com.google.android.material.textfield.TextInputLayout>
Expand Down
4 changes: 2 additions & 2 deletions org.envirocar.app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
<!-- ################# -->
<string name="report_issue_header">Report an Issue</string>
<string name="report_issue_summary">Summary of what went wrong</string>
<string name="report_issue_time_since_crash">Time since crash:</string>
<string name="report_issue_minutes">in minutes</string>
<string name="report_issue_time_since_crash">Estimated time</string>
<string name="report_issue_minutes">10:00</string>

<string name="report_issue_no_checkbox_selected_title">No Checkbox Selected</string>
<string name="report_issue_no_checkbox_selected_content">You have not selected any of the checkboxes. These help developers sort through issues quickly and resolve them. Please consider filling those that are relevant.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@
import java.io.FileFilter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -312,7 +314,7 @@ private String createComments() {
}

private String createEstimatedTimeStamp() {
long now = System.currentTimeMillis();

String text;
try {
text = whenField.getText().toString();
Expand All @@ -321,15 +323,24 @@ private String createEstimatedTimeStamp() {
text = null;
}

int delta;
if (text == null || text.isEmpty()) {
delta = 0;
} else {
delta = Integer.parseInt(text);
}
String[] hoursAndMinutes = text.split(":");

Date date = new Date(now - delta * 1000 * 60);
return SimpleDateFormat.getDateTimeInstance().format(date);
Calendar calendar = Calendar.getInstance();

if(hoursAndMinutes.length > 1){
try {
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hoursAndMinutes[0]));
} catch (Exception e) {
LOG.info("Could not parse hour of day.");
}

try {
calendar.set(Calendar.MINUTE, Integer.parseInt(hoursAndMinutes[1]));
} catch (Exception e) {
LOG.info("Could not parse minute.");
}
}
return SimpleDateFormat.getDateTimeInstance().format(calendar.getTime());
}


Expand Down

0 comments on commit f7a98c7

Please sign in to comment.