Improved history display

This commit is contained in:
Sylvain Berfini 2012-12-11 17:21:02 +01:00
parent bc23809b15
commit 615e08ef89
12 changed files with 152 additions and 59 deletions

View file

@ -4,5 +4,5 @@
android:state_pressed="true" android:state_pressed="true"
android:drawable="@color/main_app_color" /> android:drawable="@color/main_app_color" />
<item <item
android:drawable="@android:color/transparent" /> android:drawable="@android:color/white" />
</selector> </selector>

View file

@ -4,7 +4,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingBottom="10dp"
android:background="@drawable/list_selector" android:background="@drawable/list_selector"
android:orientation="vertical" > android:orientation="vertical" >

View file

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/white" android:background="@drawable/background"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout <LinearLayout
@ -27,7 +27,7 @@
android:text="@string/button_all_contacts" android:text="@string/button_all_contacts"
android:gravity="center" android:gravity="center"
android:paddingTop="20dp" android:paddingTop="20dp"
android:textSize="13dp" android:textSize="13sp"
android:textColor="@drawable/text_switch_button_color" android:textColor="@drawable/text_switch_button_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -42,7 +42,7 @@
android:text="@string/button_sip_contacts" android:text="@string/button_sip_contacts"
android:gravity="center" android:gravity="center"
android:paddingTop="20dp" android:paddingTop="20dp"
android:textSize="13dp" android:textSize="13sp"
android:textColor="@drawable/text_switch_button_color" android:textColor="@drawable/text_switch_button_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -57,7 +57,7 @@
android:text="@string/button_add_contact" android:text="@string/button_add_contact"
android:gravity="center" android:gravity="center"
android:paddingTop="20dp" android:paddingTop="20dp"
android:textSize="13dp" android:textSize="13sp"
android:textColor="@drawable/text_button" android:textColor="@drawable/text_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -4,55 +4,72 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:background="@drawable/list_selector" android:background="@drawable/list_selector"
android:orientation="horizontal" > android:orientation="vertical" >
<ImageView <TextView
android:contentDescription="@string/content_description_call_direction" android:id="@+id/separator"
android:id="@+id/icon" android:paddingLeft="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/numpad_background_top"
android:textColor="@android:color/white"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:gravity="center_vertical"
android:layout_weight="0.9" android:orientation="horizontal" >
android:src="@drawable/call_status_incoming"
android:layout_marginLeft="5dp"/> <ImageView
android:contentDescription="@string/content_description_call_direction"
<TextView android:id="@+id/icon"
android:id="@+id/sipUri" android:layout_width="match_parent"
android:lines="1" android:layout_height="wrap_content"
android:textSize="30sp" android:adjustViewBounds="true"
android:layout_width="match_parent" android:layout_weight="0.9"
android:layout_height="wrap_content" android:src="@drawable/call_status_incoming"
android:ellipsize="marquee" android:layout_marginLeft="5dp"/>
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true" <TextView
android:fadingEdge="horizontal" android:id="@+id/sipUri"
android:singleLine="true" android:lines="1"
android:layout_weight="0.2" android:textSize="30sp"
android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="match_parent"
android:textColor="@android:color/black" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" /> android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
<ImageView android:scrollHorizontally="true"
android:contentDescription="@string/content_description_detail" android:fadingEdge="horizontal"
android:id="@+id/detail" android:singleLine="true"
android:layout_width="match_parent" android:layout_weight="0.2"
android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"
android:adjustViewBounds="true" android:textColor="@android:color/black"
android:layout_weight="0.9" android:layout_marginLeft="10dp" />
android:src="@drawable/list_detail"
android:layout_marginLeft="5dp" <ImageView
android:layout_marginRight="5dp" /> android:contentDescription="@string/content_description_detail"
android:id="@+id/detail"
<ImageView android:layout_width="match_parent"
android:contentDescription="@string/content_description_delete" android:layout_height="wrap_content"
android:id="@+id/delete" android:adjustViewBounds="true"
android:layout_width="match_parent" android:layout_weight="0.9"
android:layout_height="wrap_content" android:src="@drawable/list_detail"
android:adjustViewBounds="true" android:layout_marginLeft="5dp"
android:layout_weight="0.9" android:layout_marginRight="5dp" />
android:visibility="gone"
android:src="@drawable/list_delete" <ImageView
android:layout_marginLeft="5dp" android:contentDescription="@string/content_description_delete"
android:layout_marginRight="5dp" /> android:id="@+id/delete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_weight="0.9"
android:visibility="gone"
android:src="@drawable/list_delete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="messages_date_format">HH:mm d MMM</string> <string name="history_detail_date_format">EEEE d MMM HH:mm</string>
<string name="today_date_format">HH:mm</string>
<string name="app_name">Linphone</string> <string name="app_name">Linphone</string>
<string name="notification_title">Linphone</string> <string name="notification_title">Linphone</string>

View file

@ -360,4 +360,7 @@
<string name="error_call_declined">Appel rejeté</string> <string name="error_call_declined">Appel rejeté</string>
<string name="error_user_not_found">Utilisateur non trouvé</string> <string name="error_user_not_found">Utilisateur non trouvé</string>
<string name="error_incompatible_media">Paramètres média incompatibles</string> <string name="error_incompatible_media">Paramètres média incompatibles</string>
<string name="today">Aujourd\'hui</string>
<string name="yesterday">Hier</string>
</resources> </resources>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="history_date_format">d MMM</string>
<string name="history_detail_date_format">EEEE MMM d HH:mm</string>
<string name="messages_date_format">HH:mm d MMM</string> <string name="messages_date_format">HH:mm d MMM</string>
<string name="today_date_format">HH:mm</string> <string name="today_date_format">HH:mm</string>
<string name="picture_name_format">linphone-mms-%s.jpg</string> <string name="picture_name_format">linphone-mms-%s.jpg</string>

View file

@ -407,4 +407,7 @@
<string name="error_call_declined">Call declined</string> <string name="error_call_declined">Call declined</string>
<string name="error_user_not_found">User not found</string> <string name="error_user_not_found">User not found</string>
<string name="error_incompatible_media">Incompatible media parameters</string> <string name="error_incompatible_media">Incompatible media parameters</string>
<string name="today">Today</string>
<string name="yesterday">Yesterday</string>
</resources> </resources>

View file

@ -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 along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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 org.linphone.ui.AvatarWithShadow;
import android.annotation.SuppressLint;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -91,7 +95,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
contactAddress.setText(sipUri); contactAddress.setText(sipUri);
callDirection.setText(status); callDirection.setText(status);
time.setText(callTime == null ? "" : callTime); 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) { 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); 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());
}
} }

View file

@ -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 along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar;
import java.util.List; import java.util.List;
import org.linphone.core.CallDirection; import org.linphone.core.CallDirection;
@ -26,6 +28,7 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCallLog; import org.linphone.core.LinphoneCallLog;
import org.linphone.core.LinphoneCallLog.CallStatus; import org.linphone.core.LinphoneCallLog.CallStatus;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
@ -297,6 +300,40 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener,
public long getItemId(int position) { public long getItemId(int position) {
return 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) { public View getView(int position, View convertView, ViewGroup parent) {
View view = null; View view = null;
@ -307,15 +344,34 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener,
} }
final LinphoneCallLog log = mLogs.get(position); final LinphoneCallLog log = mLogs.get(position);
long timestamp = log.getTimestamp();
final LinphoneAddress address; final LinphoneAddress address;
TextView contact = (TextView) view.findViewById(R.id.sipUri); 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 detail = (ImageView) view.findViewById(R.id.detail);
ImageView delete = (ImageView) view.findViewById(R.id.delete); ImageView delete = (ImageView) view.findViewById(R.id.delete);
ImageView callDirection = (ImageView) view.findViewById(R.id.icon); 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) { if (log.getDirection() == CallDirection.Incoming) {
address = log.getFrom(); address = log.getFrom();
if (log.getStatus() == CallStatus.Missed) { if (log.getStatus() == CallStatus.Missed) {

View file

@ -445,7 +445,7 @@ public class LinphoneActivity extends FragmentActivity implements
} }
String callTime = secondsToDisplayableString(log.getCallDuration()); String callTime = secondsToDisplayableString(log.getCallDuration());
String callDate = log.getStartDate(); String callDate = String.valueOf(log.getTimestamp());
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2); Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.HISTORY_DETAIL) { if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.HISTORY_DETAIL) {

@ -1 +1 @@
Subproject commit 1e75dc40229e1f8e6e5c6c121957722f11c03a3e Subproject commit 28912d223403c8164b35d14d5b5925b61e4b65ac