diff --git a/res/drawable/list_selector.xml b/res/drawable/list_selector.xml index 0b37006b5..7ae5b7b7a 100644 --- a/res/drawable/list_selector.xml +++ b/res/drawable/list_selector.xml @@ -4,5 +4,5 @@ android:state_pressed="true" android:drawable="@color/main_app_color" /> + android:drawable="@android:color/white" /> \ No newline at end of file diff --git a/res/layout/contact_cell.xml b/res/layout/contact_cell.xml index 5f4230d22..d29f9454d 100644 --- a/res/layout/contact_cell.xml +++ b/res/layout/contact_cell.xml @@ -4,7 +4,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" - android:paddingBottom="10dp" android:background="@drawable/list_selector" android:orientation="vertical" > diff --git a/res/layout/contacts_list.xml b/res/layout/contacts_list.xml index 9181c5b5e..ff9a324e5 100644 --- a/res/layout/contacts_list.xml +++ b/res/layout/contacts_list.xml @@ -2,7 +2,7 @@ + android:orientation="vertical" > - + + - - - - - - + android:gravity="center_vertical" + android:orientation="horizontal" > + + + + + + + + + + \ No newline at end of file diff --git a/res/values-FR/custom.xml b/res/values-FR/custom.xml index b5030f574..c6281c118 100644 --- a/res/values-FR/custom.xml +++ b/res/values-FR/custom.xml @@ -1,8 +1,7 @@ - HH:mm d MMM - HH:mm + EEEE d MMM HH:mm Linphone Linphone diff --git a/res/values-FR/strings.xml b/res/values-FR/strings.xml index b0b86e5c2..2d6b14c30 100644 --- a/res/values-FR/strings.xml +++ b/res/values-FR/strings.xml @@ -360,4 +360,7 @@ Appel rejeté Utilisateur non trouvé Paramètres média incompatibles + + Aujourd\'hui + Hier diff --git a/res/values/custom.xml b/res/values/custom.xml index e01d010a4..ad865d8d9 100644 --- a/res/values/custom.xml +++ b/res/values/custom.xml @@ -1,6 +1,8 @@ + d MMM + EEEE MMM d HH:mm HH:mm d MMM HH:mm linphone-mms-%s.jpg diff --git a/res/values/strings.xml b/res/values/strings.xml index 2a598984e..e9f81d511 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -407,4 +407,7 @@ Call declined User not found Incompatible media parameters + + Today + Yesterday diff --git a/src/org/linphone/HistoryDetailFragment.java b/src/org/linphone/HistoryDetailFragment.java index 6e75068b9..150a5aaa9 100644 --- a/src/org/linphone/HistoryDetailFragment.java +++ b/src/org/linphone/HistoryDetailFragment.java @@ -17,8 +17,12 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +import java.text.SimpleDateFormat; +import java.util.Calendar; + import org.linphone.ui.AvatarWithShadow; +import android.annotation.SuppressLint; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -91,7 +95,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { contactAddress.setText(sipUri); callDirection.setText(status); time.setText(callTime == null ? "" : callTime); - date.setText(callDate == null ? "" : callDate); + date.setText(timestampToHumanDate(callDate)); } public void changeDisplayedHistory(String sipUri, String displayName, String pictureUri, String status, String callTime, String callDate) { @@ -125,4 +129,14 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener { LinphoneActivity.instance().displayContactsForEdition(sipUri); } } + + @SuppressLint("SimpleDateFormat") + private String timestampToHumanDate(String timestamp) { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(Long.parseLong(timestamp)); + + SimpleDateFormat dateFormat; + dateFormat = new SimpleDateFormat(getResources().getString(R.string.history_detail_date_format)); + return dateFormat.format(cal.getTime()); + } } diff --git a/src/org/linphone/HistorySimpleFragment.java b/src/org/linphone/HistorySimpleFragment.java index 567c9387c..cef802519 100644 --- a/src/org/linphone/HistorySimpleFragment.java +++ b/src/org/linphone/HistorySimpleFragment.java @@ -17,8 +17,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; import org.linphone.core.CallDirection; @@ -26,6 +28,7 @@ import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCallLog; import org.linphone.core.LinphoneCallLog.CallStatus; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -297,6 +300,40 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, public long getItemId(int position) { return position; } + + @SuppressLint("SimpleDateFormat") + private String timestampToHumanDate(Calendar cal) { + SimpleDateFormat dateFormat; + if (isToday(cal)) { + return getString(R.string.today); + } else if (isYesterday(cal)) { + return getString(R.string.yesterday); + } else { + dateFormat = new SimpleDateFormat(getResources().getString(R.string.history_date_format)); + } + + return dateFormat.format(cal.getTime()); + } + + private boolean isSameDay(Calendar cal1, Calendar cal2) { + if (cal1 == null || cal2 == null) { + return false; + } + + return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && + cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && + cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)); + } + + private boolean isToday(Calendar cal) { + return isSameDay(cal, Calendar.getInstance()); + } + + private boolean isYesterday(Calendar cal) { + Calendar yesterday = Calendar.getInstance(); + yesterday.roll(Calendar.DAY_OF_MONTH, -1); + return isSameDay(cal, yesterday); + } public View getView(int position, View convertView, ViewGroup parent) { View view = null; @@ -307,15 +344,34 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, } final LinphoneCallLog log = mLogs.get(position); + long timestamp = log.getTimestamp(); final LinphoneAddress address; TextView contact = (TextView) view.findViewById(R.id.sipUri); - contact.setSelected(true); // For animation + contact.setSelected(true); // For automated horizontal scrolling of long texts ImageView detail = (ImageView) view.findViewById(R.id.detail); ImageView delete = (ImageView) view.findViewById(R.id.delete); ImageView callDirection = (ImageView) view.findViewById(R.id.icon); + TextView separator = (TextView) view.findViewById(R.id.separator); + Calendar logTime = Calendar.getInstance(); + logTime.setTimeInMillis(timestamp); + separator.setText(timestampToHumanDate(logTime)); + + if (position > 0) { + LinphoneCallLog previousLog = mLogs.get(position-1); + long previousTimestamp = previousLog.getTimestamp(); + Calendar previousLogTime = Calendar.getInstance(); + previousLogTime.setTimeInMillis(previousTimestamp); + + if (isSameDay(previousLogTime, logTime)) { + separator.setVisibility(View.GONE); + } else { + separator.setVisibility(View.VISIBLE); + } + } + if (log.getDirection() == CallDirection.Incoming) { address = log.getFrom(); if (log.getStatus() == CallStatus.Missed) { diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index e504a3d5b..d3dd11734 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -445,7 +445,7 @@ public class LinphoneActivity extends FragmentActivity implements } String callTime = secondsToDisplayableString(log.getCallDuration()); - String callDate = log.getStartDate(); + String callDate = String.valueOf(log.getTimestamp()); Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2); if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.HISTORY_DETAIL) { diff --git a/submodules/linphone b/submodules/linphone index 1e75dc402..28912d223 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 1e75dc40229e1f8e6e5c6c121957722f11c03a3e +Subproject commit 28912d223403c8164b35d14d5b5925b61e4b65ac