diff --git a/res/drawable-xhdpi/call_incoming.png b/res/drawable-xhdpi/call_incoming.png new file mode 100644 index 000000000..89d593a4c Binary files /dev/null and b/res/drawable-xhdpi/call_incoming.png differ diff --git a/res/drawable-xhdpi/call_missed.png b/res/drawable-xhdpi/call_missed.png new file mode 100644 index 000000000..e1074ffaf Binary files /dev/null and b/res/drawable-xhdpi/call_missed.png differ diff --git a/res/drawable-xhdpi/call_outgoing.png b/res/drawable-xhdpi/call_outgoing.png new file mode 100644 index 000000000..c6df94bd9 Binary files /dev/null and b/res/drawable-xhdpi/call_outgoing.png differ diff --git a/res/layout/active_call_control_row.xml b/res/layout/call_inactive_row.xml similarity index 100% rename from res/layout/active_call_control_row.xml rename to res/layout/call_inactive_row.xml diff --git a/res/layout/history.xml b/res/layout/history.xml index 157f56a08..888fffc42 100644 --- a/res/layout/history.xml +++ b/res/layout/history.xml @@ -7,10 +7,10 @@ + android:layout_gravity="top"> + android:layout_gravity="bottom"> + + + android:layout_height="wrap_content"/> diff --git a/src/org/linphone/FragmentsAvailable.java b/src/org/linphone/FragmentsAvailable.java index 700586eac..053cfbe91 100644 --- a/src/org/linphone/FragmentsAvailable.java +++ b/src/org/linphone/FragmentsAvailable.java @@ -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; diff --git a/src/org/linphone/HistoryDetailFragment.java b/src/org/linphone/HistoryDetailFragment.java index 2e93a1fcb..de8c3ef76 100644 --- a/src/org/linphone/HistoryDetailFragment.java +++ b/src/org/linphone/HistoryDetailFragment.java @@ -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()); - } } diff --git a/src/org/linphone/HistoryFragment.java b/src/org/linphone/HistoryListFragment.java similarity index 90% rename from src/org/linphone/HistoryFragment.java rename to src/org/linphone/HistoryListFragment.java index f1e717360..af7088648 100644 --- a/src/org/linphone/HistoryFragment.java +++ b/src/org/linphone/HistoryListFragment.java @@ -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 missedCalls = new ArrayList(); @@ -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);