Improved history display
This commit is contained in:
parent
bc23809b15
commit
615e08ef89
12 changed files with 152 additions and 59 deletions
|
@ -4,5 +4,5 @@
|
|||
android:state_pressed="true"
|
||||
android:drawable="@color/main_app_color" />
|
||||
<item
|
||||
android:drawable="@android:color/transparent" />
|
||||
android:drawable="@android:color/white" />
|
||||
</selector>
|
|
@ -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" >
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:background="@drawable/background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
|
@ -27,7 +27,7 @@
|
|||
android:text="@string/button_all_contacts"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textSize="13dp"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@drawable/text_switch_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -42,7 +42,7 @@
|
|||
android:text="@string/button_sip_contacts"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textSize="13dp"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@drawable/text_switch_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -57,7 +57,7 @@
|
|||
android:text="@string/button_add_contact"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textSize="13dp"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -4,55 +4,72 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/list_selector"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_call_direction"
|
||||
android:id="@+id/icon"
|
||||
<TextView
|
||||
android:id="@+id/separator"
|
||||
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_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/call_status_incoming"
|
||||
android:layout_marginLeft="5dp"/>
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sipUri"
|
||||
android:lines="1"
|
||||
android:textSize="30sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:layout_weight="0.2"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_marginLeft="10dp" />
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_call_direction"
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/call_status_incoming"
|
||||
android:layout_marginLeft="5dp"/>
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_detail"
|
||||
android:id="@+id/detail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/list_detail"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
<TextView
|
||||
android:id="@+id/sipUri"
|
||||
android:lines="1"
|
||||
android:textSize="30sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:layout_weight="0.2"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
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" />
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_detail"
|
||||
android:id="@+id/detail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="0.9"
|
||||
android:src="@drawable/list_detail"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
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>
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="messages_date_format">HH:mm d MMM</string>
|
||||
<string name="today_date_format">HH:mm</string>
|
||||
<string name="history_detail_date_format">EEEE d MMM HH:mm</string>
|
||||
|
||||
<string name="app_name">Linphone</string>
|
||||
<string name="notification_title">Linphone</string>
|
||||
|
|
|
@ -360,4 +360,7 @@
|
|||
<string name="error_call_declined">Appel rejeté</string>
|
||||
<string name="error_user_not_found">Utilisateur non trouvé</string>
|
||||
<string name="error_incompatible_media">Paramètres média incompatibles</string>
|
||||
|
||||
<string name="today">Aujourd\'hui</string>
|
||||
<string name="yesterday">Hier</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="today_date_format">HH:mm</string>
|
||||
<string name="picture_name_format">linphone-mms-%s.jpg</string>
|
||||
|
|
|
@ -407,4 +407,7 @@
|
|||
<string name="error_call_declined">Call declined</string>
|
||||
<string name="error_user_not_found">User not found</string>
|
||||
<string name="error_incompatible_media">Incompatible media parameters</string>
|
||||
|
||||
<string name="today">Today</string>
|
||||
<string name="yesterday">Yesterday</string>
|
||||
</resources>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -298,6 +301,40 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener,
|
|||
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;
|
||||
if (convertView != 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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1e75dc40229e1f8e6e5c6c121957722f11c03a3e
|
||||
Subproject commit 28912d223403c8164b35d14d5b5925b61e4b65ac
|
Loading…
Reference in a new issue