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

View file

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

View file

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

View file

@ -41,8 +41,8 @@ import android.widget.TextView;
public class HistoryDetailFragment extends Fragment implements OnClickListener {
private ImageView dialBack, chat, addToContacts, back;
private View view;
private ImageView contactPicture;
private TextView contactName, contactAddress, callDirection, time, date;
private ImageView contactPicture, callDirection;
private TextView contactName, contactAddress, time, date;
private String sipUri, displayName, pictureUri;
@Override
@ -74,13 +74,13 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
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);
}
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);
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) {
contactName.setText(displayName == null ? sipUri : displayName);
if (getResources().getBoolean(R.bool.never_display_sip_addresses)) {
if (displayName == null) {
contactAddress.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
} else {
contactAddress.setText(sipUri);
}
if (status.equals("Missed")) {
callDirection.setText(getString(R.string.call_state_missed) + " call");
callDirection.setImageResource(R.drawable.call_missed);
} 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")) {
callDirection.setText(getString(R.string.call_state_outgoing) + " call");
} else {
callDirection.setText(status);
callDirection.setImageResource(R.drawable.call_outgoing);
}
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;
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) {
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
if (displayName == null ) {
displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
}
@ -144,10 +143,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_DETAIL);
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
LinphoneActivity.instance().hideStatusBar();
}
LinphoneActivity.instance().hideTabBar(false);
}
}
@ -163,20 +159,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
LinphoneActivity.instance().displayChat(sipUri);
} else if (id == R.id.add_contact) {
String uriToAdd = sipUri;
if (getResources().getBoolean(R.bool.never_display_sip_addresses)) {
uriToAdd = LinphoneUtils.getUsernameFromAddress(sipUri);
}
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;
/*
HistoryFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
HistoryListFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -56,7 +56,7 @@ import android.widget.TextView;
/**
* @author Sylvain Berfini
*/
public class HistoryFragment extends Fragment implements OnClickListener, OnItemClickListener {
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener {
private ListView historyList;
private LayoutInflater mInflater;
private TextView noCallHistory, noMissedCallHistory;
@ -71,10 +71,10 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
mInflater = inflater;
View view = inflater.inflate(R.layout.history, container, false);
noCallHistory = (TextView) view.findViewById(R.id.noCallHistory);
noMissedCallHistory = (TextView) view.findViewById(R.id.noMissedCallHistory);
noCallHistory = (TextView) view.findViewById(R.id.no_call_history);
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);
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() {
if (onlyDisplayMissedCalls) {
List<LinphoneCallLog> missedCalls = new ArrayList<LinphoneCallLog>();
@ -171,7 +194,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
super.onResume();
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());
@ -188,12 +213,14 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
if (id == R.id.select_all) {
deselectAll.setVisibility(View.VISIBLE);
selectAll.setVisibility(View.GONE);
enabledDeleteButton(true);
selectAllList(true);
return;
}
if (id == R.id.deselect_all) {
deselectAll.setVisibility(View.GONE);
selectAll.setVisibility(View.VISIBLE);
enabledDeleteButton(false);
selectAllList(false);
return;
}
@ -252,6 +279,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
if (id == R.id.edit) {
topBar.setVisibility(View.GONE);
editList.setVisibility(View.VISIBLE);
enabledDeleteButton(false);
isEditMode = true;
}
@ -474,17 +502,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
}
if (displayName == null) {
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
holder.contact.setText(address.getUserName());
} else {
holder.contact.setText(sipUri);
}
holder.contact.setText(LinphoneUtils.getAddressDisplayName(sipUri));
} else {
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(address.getDisplayName())) {
holder.contact.setText(displayName);
} else {
holder.contact.setText(sipUri);
}
holder.contact.setText(displayName);
}
//view.setTag(sipUri);
@ -494,6 +514,21 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean 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);