Add new images history detail and fix history edit mode

This commit is contained in:
Margaux Clerc 2015-10-26 19:25:54 +01:00
parent 4e9151ad79
commit 3d3a1c4f23
9 changed files with 88 additions and 68 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

View file

@ -7,10 +7,10 @@
<RelativeLayout <RelativeLayout
android:id="@+id/top_bar" android:id="@+id/top_bar"
android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_gravity="top" android:layout_gravity="top">
android:background="@color/colorF">
<RelativeLayout <RelativeLayout
android:id="@+id/all_calls_layout" android:id="@+id/all_calls_layout"
@ -80,7 +80,7 @@
<include layout="@layout/edit_list"/> <include layout="@layout/edit_list"/>
<ListView <ListView
android:id="@+id/historyList" android:id="@+id/history_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:divider="@color/colorE" android:divider="@color/colorE"
@ -88,7 +88,7 @@
android:dividerHeight="1dp" /> android:dividerHeight="1dp" />
<TextView <TextView
android:id="@+id/noCallHistory" android:id="@+id/no_call_history"
android:text="@string/no_call_history" android:text="@string/no_call_history"
style="@style/font6" style="@style/font6"
android:visibility="gone" android:visibility="gone"
@ -97,7 +97,7 @@
android:gravity="center"/> android:gravity="center"/>
<TextView <TextView
android:id="@+id/noMissedCallHistory" android:id="@+id/no_missed_call_history"
android:text="@string/no_missed_call_history" android:text="@string/no_missed_call_history"
style="@style/font6" style="@style/font6"
android:visibility="gone" android:visibility="gone"

View file

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/colorH"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorH"
android:orientation="vertical" > android:orientation="vertical" >
<RelativeLayout <RelativeLayout
android:id="@+id/relativeLayout" android:background="@color/colorF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_gravity="bottom" android:layout_gravity="bottom">
android:background="@color/colorF">
<ImageView <ImageView
android:id="@+id/back" android:id="@+id/back"
@ -134,7 +133,6 @@
android:layout_marginRight="10dp"/> android:layout_marginRight="10dp"/>
<TextView <TextView
android:id="@+id/call_direction"
android:text="@string/call" android:text="@string/call"
style="@style/font13" style="@style/font13"
android:textAllCaps="true" android:textAllCaps="true"
@ -150,6 +148,14 @@
android:gravity="center" android:gravity="center"
android:padding="10dp"> android:padding="10dp">
<ImageView
android:id="@+id/direction"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView <TextView
android:id="@+id/date" android:id="@+id/date"
style="@style/font10" style="@style/font10"
@ -161,7 +167,7 @@
android:id="@+id/time" android:id="@+id/time"
style="@style/font10" style="@style/font10"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -23,14 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
public enum FragmentsAvailable { public enum FragmentsAvailable {
UNKNOW, UNKNOW,
DIALER, DIALER,
HISTORY, HISTORY_LIST,
HISTORY_DETAIL, HISTORY_DETAIL,
CONTACTS, CONTACTS,
CONTACT, CONTACT,
EDIT_CONTACT, EDIT_CONTACT,
ABOUT, ABOUT,
ABOUT_INSTEAD_OF_SETTINGS,
ABOUT_INSTEAD_OF_CHAT,
ACCOUNT_SETTINGS, ACCOUNT_SETTINGS,
SETTINGS, SETTINGS,
CHATLIST, CHATLIST,
@ -42,11 +40,11 @@ public enum FragmentsAvailable {
public boolean isRightOf(FragmentsAvailable fragment) { public boolean isRightOf(FragmentsAvailable fragment) {
switch (this) { switch (this) {
case HISTORY: case HISTORY_LIST:
return fragment == UNKNOW; return fragment == UNKNOW;
case HISTORY_DETAIL: case HISTORY_DETAIL:
return HISTORY.isRightOf(fragment) || fragment == HISTORY; return HISTORY_LIST.isRightOf(fragment) || fragment == HISTORY_LIST;
case CONTACTS: case CONTACTS:
return HISTORY_DETAIL.isRightOf(fragment) || fragment == HISTORY_DETAIL; return HISTORY_DETAIL.isRightOf(fragment) || fragment == HISTORY_DETAIL;
@ -60,13 +58,11 @@ public enum FragmentsAvailable {
case DIALER: case DIALER:
return EDIT_CONTACT.isRightOf(fragment) || fragment == EDIT_CONTACT; return EDIT_CONTACT.isRightOf(fragment) || fragment == EDIT_CONTACT;
case ABOUT_INSTEAD_OF_CHAT:
case CHATLIST: case CHATLIST:
return DIALER.isRightOf(fragment) || fragment == DIALER; return DIALER.isRightOf(fragment) || fragment == DIALER;
case ABOUT_INSTEAD_OF_SETTINGS:
case SETTINGS: case SETTINGS:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT; return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
case ABOUT: case ABOUT:
case ACCOUNT_SETTINGS: case ACCOUNT_SETTINGS:
@ -83,7 +79,7 @@ public enum FragmentsAvailable {
public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) { public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) {
switch (this) { switch (this) {
case HISTORY_DETAIL: case HISTORY_DETAIL:
return fragment == HISTORY; return fragment == HISTORY_LIST;
case CONTACT: case CONTACT:
return fragment == CONTACTS; return fragment == CONTACTS;

View file

@ -41,8 +41,8 @@ import android.widget.TextView;
public class HistoryDetailFragment extends Fragment implements OnClickListener { public class HistoryDetailFragment extends Fragment implements OnClickListener {
private ImageView dialBack, chat, addToContacts, back; private ImageView dialBack, chat, addToContacts, back;
private View view; private View view;
private ImageView contactPicture; private ImageView contactPicture, callDirection;
private TextView contactName, contactAddress, callDirection, time, date; private TextView contactName, contactAddress, time, date;
private String sipUri, displayName, pictureUri; private String sipUri, displayName, pictureUri;
@Override @Override
@ -74,13 +74,13 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
contactPicture = (ImageView) view.findViewById(R.id.contact_picture); contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
contactName = (TextView) view.findViewById(R.id.contact_name); contactName = (TextView) view.findViewById(R.id.contact_name);
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) { if (displayName == null) {
displayName = LinphoneUtils.getUsernameFromAddress(sipUri); displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
} }
contactAddress = (TextView) view.findViewById(R.id.contact_address); contactAddress = (TextView) view.findViewById(R.id.contact_address);
callDirection = (TextView) view.findViewById(R.id.call_direction); callDirection = (ImageView) view.findViewById(R.id.direction);
time = (TextView) view.findViewById(R.id.time); time = (TextView) view.findViewById(R.id.time);
date = (TextView) view.findViewById(R.id.date); date = (TextView) view.findViewById(R.id.date);
@ -92,24 +92,23 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
private void displayHistory(String status, String callTime, String callDate) { private void displayHistory(String status, String callTime, String callDate) {
contactName.setText(displayName == null ? sipUri : displayName); contactName.setText(displayName == null ? sipUri : displayName);
if (getResources().getBoolean(R.bool.never_display_sip_addresses)) { if (displayName == null) {
contactAddress.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); contactAddress.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
} else { } else {
contactAddress.setText(sipUri); contactAddress.setText(sipUri);
} }
if (status.equals("Missed")) { if (status.equals("Missed")) {
callDirection.setText(getString(R.string.call_state_missed) + " call"); callDirection.setImageResource(R.drawable.call_missed);
} else if (status.equals("Incoming")) { } else if (status.equals("Incoming")) {
callDirection.setText(getString(R.string.call_state_incoming) + " call"); callDirection.setImageResource(R.drawable.call_incoming);
} else if (status.equals("Outgoing")) { } else if (status.equals("Outgoing")) {
callDirection.setText(getString(R.string.call_state_outgoing) + " call"); callDirection.setImageResource(R.drawable.call_outgoing);
} else {
callDirection.setText(status);
} }
time.setText(callTime == null ? "" : callTime); time.setText(callTime == null ? "" : callTime);
date.setText(timestampToHumanDate(callDate)); Long longDate = Long.parseLong(callDate);
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),longDate,getString(R.string.history_detail_date_format)));
LinphoneAddress lAddress; LinphoneAddress lAddress;
try { try {
@ -128,7 +127,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
} }
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) {
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) { if (displayName == null ) {
displayName = LinphoneUtils.getUsernameFromAddress(sipUri); displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
} }
@ -144,10 +143,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_DETAIL); LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_DETAIL);
LinphoneActivity.instance().hideTabBar(false);
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
LinphoneActivity.instance().hideStatusBar();
}
} }
} }
@ -163,20 +159,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
LinphoneActivity.instance().displayChat(sipUri); LinphoneActivity.instance().displayChat(sipUri);
} else if (id == R.id.add_contact) { } else if (id == R.id.add_contact) {
String uriToAdd = sipUri; String uriToAdd = sipUri;
if (getResources().getBoolean(R.bool.never_display_sip_addresses)) {
uriToAdd = LinphoneUtils.getUsernameFromAddress(sipUri);
}
LinphoneActivity.instance().displayContactsForEdition(uriToAdd); LinphoneActivity.instance().displayContactsForEdition(uriToAdd);
} }
} }
@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

@ -1,7 +1,7 @@
package org.linphone; package org.linphone;
/* /*
HistoryFragment.java HistoryListFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
@ -56,7 +56,7 @@ import android.widget.TextView;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class HistoryFragment extends Fragment implements OnClickListener, OnItemClickListener { public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener {
private ListView historyList; private ListView historyList;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private TextView noCallHistory, noMissedCallHistory; private TextView noCallHistory, noMissedCallHistory;
@ -71,10 +71,10 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
mInflater = inflater; mInflater = inflater;
View view = inflater.inflate(R.layout.history, container, false); View view = inflater.inflate(R.layout.history, container, false);
noCallHistory = (TextView) view.findViewById(R.id.noCallHistory); noCallHistory = (TextView) view.findViewById(R.id.no_call_history);
noMissedCallHistory = (TextView) view.findViewById(R.id.noMissedCallHistory); noMissedCallHistory = (TextView) view.findViewById(R.id.no_missed_call_history);
historyList = (ListView) view.findViewById(R.id.historyList); historyList = (ListView) view.findViewById(R.id.history_list);
historyList.setOnItemClickListener(this); historyList.setOnItemClickListener(this);
delete = (ImageView) view.findViewById(R.id.delete); delete = (ImageView) view.findViewById(R.id.delete);
@ -134,6 +134,29 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
} }
} }
public int getNbItemsChecked(){
int size = historyList.getAdapter().getCount();
int nb = 0;
for(int i=0; i<size; i++) {
if(historyList.isItemChecked(i)) {
nb ++;
}
}
return nb;
}
public void enabledDeleteButton(Boolean enabled){
if(enabled){
delete.setEnabled(true);
delete.setAlpha(1f);
} else {
if (getNbItemsChecked() == 0){
delete.setEnabled(false);
delete.setAlpha(0.2f);
}
}
}
private void removeNotMissedCallsFromLogs() { private void removeNotMissedCallsFromLogs() {
if (onlyDisplayMissedCalls) { if (onlyDisplayMissedCalls) {
List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>(); List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>();
@ -171,7 +194,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
super.onResume(); super.onResume();
if (LinphoneActivity.isInstanciated()) { if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY); LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_LIST);
LinphoneActivity.instance().hideTabBar(false);
LinphoneActivity.instance().displayMissedCalls(0);
} }
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs()); mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
@ -188,12 +213,14 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
if (id == R.id.select_all) { if (id == R.id.select_all) {
deselectAll.setVisibility(View.VISIBLE); deselectAll.setVisibility(View.VISIBLE);
selectAll.setVisibility(View.GONE); selectAll.setVisibility(View.GONE);
enabledDeleteButton(true);
selectAllList(true); selectAllList(true);
return; return;
} }
if (id == R.id.deselect_all) { if (id == R.id.deselect_all) {
deselectAll.setVisibility(View.GONE); deselectAll.setVisibility(View.GONE);
selectAll.setVisibility(View.VISIBLE); selectAll.setVisibility(View.VISIBLE);
enabledDeleteButton(false);
selectAllList(false); selectAllList(false);
return; return;
} }
@ -252,6 +279,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
if (id == R.id.edit) { if (id == R.id.edit) {
topBar.setVisibility(View.GONE); topBar.setVisibility(View.GONE);
editList.setVisibility(View.VISIBLE); editList.setVisibility(View.VISIBLE);
enabledDeleteButton(false);
isEditMode = true; isEditMode = true;
} }
@ -474,17 +502,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
} }
if (displayName == null) { if (displayName == null) {
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) { holder.contact.setText(LinphoneUtils.getAddressDisplayName(sipUri));
holder.contact.setText(address.getUserName());
} else {
holder.contact.setText(sipUri);
}
} else { } else {
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(address.getDisplayName())) { holder.contact.setText(displayName);
holder.contact.setText(displayName);
} else {
holder.contact.setText(sipUri);
}
} }
//view.setTag(sipUri); //view.setTag(sipUri);
@ -494,6 +514,21 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) { public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
historyList.setItemChecked(position, b); historyList.setItemChecked(position, b);
if(getNbItemsChecked() == getCount()){
deselectAll.setVisibility(View.VISIBLE);
selectAll.setVisibility(View.GONE);
enabledDeleteButton(true);
} else {
if(getNbItemsChecked() == 0){
deselectAll.setVisibility(View.GONE);
selectAll.setVisibility(View.VISIBLE);
enabledDeleteButton(false);
} else {
deselectAll.setVisibility(View.GONE);
selectAll.setVisibility(View.VISIBLE);
enabledDeleteButton(true);
}
}
} }
}); });
holder.detail.setVisibility(View.INVISIBLE); holder.detail.setVisibility(View.INVISIBLE);