Add auto-offset for manual call log entry test screen.

Added ability to auto-offset the next call date/time to be manually added
to the call log.  This helps when you want to add a number of repeated
calls but offset them by a short time (eg 1 minute).

Change-Id: I66a59df47e17b99a008ca289c641301eda460b5e
diff --git a/tests/res/layout/fill_call_log_test.xml b/tests/res/layout/fill_call_log_test.xml
index 6de9b91..9b89e4a 100644
--- a/tests/res/layout/fill_call_log_test.xml
+++ b/tests/res/layout/fill_call_log_test.xml
@@ -183,4 +183,23 @@
         android:text="@string/addToCallLogButton"
         android:onClick="addManualEntry"
         />
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="left"
+        >
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/delta_after_add"
+            />
+        <EditText
+            android:id="@+id/delta_after_add"
+            android:layout_width="90dp"
+            android:layout_height="wrap_content"
+            android:text="-1"
+            android:inputType="number"
+            />
+    </LinearLayout>
 </LinearLayout>
diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml
index bdeb304..25c3a5a 100644
--- a/tests/res/values/donottranslate_strings.xml
+++ b/tests/res/values/donottranslate_strings.xml
@@ -50,4 +50,5 @@
     <string name="presentation_restricted">Restricted</string>
     <string name="presentation_unknown">Unknown</string>
     <string name="presentation_payphone">Payphone</string>
+    <string name="delta_after_add">Offset call time after add (min): </string>
 </resources>
diff --git a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
index 3a1682e..1e5c257 100644
--- a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
+++ b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
@@ -37,6 +37,7 @@
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.DatePicker;
+import android.widget.EditText;
 import android.widget.ProgressBar;
 import android.widget.RadioButton;
 import android.widget.TextView;
@@ -75,6 +76,7 @@
     private TextView mCallDate;
     private TextView mCallTime;
     private TextView mPhoneNumber;
+    private EditText mOffset;
 
     private int mCallTimeHour;
     private int mCallTimeMinute;
@@ -124,6 +126,7 @@
         mCallTime = (TextView) findViewById(R.id.call_time);
         mCallDate = (TextView) findViewById(R.id.call_date);
         mPhoneNumber = (TextView) findViewById(R.id.phone_number);
+        mOffset = (EditText) findViewById(R.id.delta_after_add);
 
         // Use the current time as the default values for the picker
         final Calendar c = Calendar.getInstance();
@@ -469,5 +472,16 @@
         Calls.addCall(null, this, mPhoneNumber.getText().toString(), getManualPresentation(),
                 getManualCallType(), dateTime.getTimeInMillis(), RNG.nextInt(60 * 60));
 
+        // Subtract offset from the call date/time and store as new date/time
+        int offset = Integer.parseInt(mOffset.getText().toString());
+
+        dateTime.add(Calendar.MINUTE, offset);
+        mCallDateYear = dateTime.get(Calendar.YEAR);
+        mCallDateMonth = dateTime.get(Calendar.MONTH);
+        mCallDateDay = dateTime.get(Calendar.DAY_OF_MONTH);
+        mCallTimeHour = dateTime.get(Calendar.HOUR_OF_DAY);
+        mCallTimeMinute = dateTime.get(Calendar.MINUTE);
+        setDisplayDate();
+        setDisplayTime();
     }
 }