From 3d3a1c4f23bacd95870642fc0f162c30bae6c534 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Mon, 26 Oct 2015 19:25:54 +0100 Subject: [PATCH] Add new images history detail and fix history edit mode --- res/drawable-xhdpi/call_incoming.png | Bin 0 -> 864 bytes res/drawable-xhdpi/call_missed.png | Bin 0 -> 698 bytes res/drawable-xhdpi/call_outgoing.png | Bin 0 -> 528 bytes ..._control_row.xml => call_inactive_row.xml} | 0 res/layout/history.xml | 10 +-- res/layout/history_detail.xml | 18 +++-- src/org/linphone/FragmentsAvailable.java | 18 ++--- src/org/linphone/HistoryDetailFragment.java | 41 +++-------- ...Fragment.java => HistoryListFragment.java} | 69 +++++++++++++----- 9 files changed, 88 insertions(+), 68 deletions(-) create mode 100644 res/drawable-xhdpi/call_incoming.png create mode 100644 res/drawable-xhdpi/call_missed.png create mode 100644 res/drawable-xhdpi/call_outgoing.png rename res/layout/{active_call_control_row.xml => call_inactive_row.xml} (100%) rename src/org/linphone/{HistoryFragment.java => HistoryListFragment.java} (90%) diff --git a/res/drawable-xhdpi/call_incoming.png b/res/drawable-xhdpi/call_incoming.png new file mode 100644 index 0000000000000000000000000000000000000000..89d593a4c7987aa3399f456fac29d730602f38c5 GIT binary patch literal 864 zcmV-m1E2hfP)AD6jX1zKB%87Yt<_z!4dofeN1| z`~d(QcEj5yigOKv#sD0Z$g@OT*`Vsd<$$d#&^38@H(T^ZcHjWavc;8tRi9cJ6n4U+ zW@MOvlM;Cz7GKi5`s8ZCmMwT3$lnz;BSQdAN#uxNuJU>HaoJp92b`3hLjX?8;0#ga z^XOx1&EM1tG>sHyk;ohb^BEbOh%Pp$-$vKVk+gy4U{Pke;phjrOd?0YsP?-Ap@<0htlU2?g!|c zM2-=mMstT>Cz4Yn0(WE?{a{qc;7nZOSHpdYu4r5aIzE={aAXwdTXGTGZCHi8$DvlqZ+iEJ@Zo#qa`*i0`G>%sGdtA`0! zWN={W;?084+xU3R^qYji>> zoSC^^^XO0P{Dz3T4>0(S-S9*V+|%6pgH(J!I^rrGXl#4uY_y5_6U>hqJo>|U4G@4_ z8;i~bQEU5q=Xbvv?h_z3u?@pwQWwtv;nQ{)AmYyeApB)|4;W1VqFcl^K`W`a?0000EKVIx3-^Jz>7 zP8+(@f?d(TKF7p0!R#vF0}gz5T*5KO#C1VU1}m4~keArwB;NdAIzGJL(KwRC{r+&9 z;skDaCIr0>{AeZTw^#7j5V|dx8Ud|^Fye&o3+e<1 zog+JyMJL-X_-z2*I`Fe;8(Gvux8SF<&6zeZ%fuGJR08s_z_!2u)SL+VCSG_gqV#9-_w z5c7Qpi~^eic$L;b0As*LU?^t#U1^)f%Nj>p4u571f_o9pxzJ#-bSOTRrh!WVjO6u1 gr`Q#L1TYNn4_^>8A0t>5w*UYD07*qoM6N<$f*bcO6#xJL literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/call_outgoing.png b/res/drawable-xhdpi/call_outgoing.png new file mode 100644 index 0000000000000000000000000000000000000000..c6df94bd910798c1a7e9f8761383284a7dae02d4 GIT binary patch literal 528 zcmV+r0`L8aP)Yx}0F~xq%s4jim=O2` z4E0%pb@B03;pYC7O1lJ1-ti9BH97pxL>iDOmL`<;P7mC?285gYQ_kc7VYu1SjDotF<;w4~KO*`5H*4JfFOi0Vj{3#{E}xB+1x`9nU7NYjs?HUF ztBwn2QR4td>2!1GN%O722gKIeflF8Oxf20+vsIZfYzg7o+Nm$qeE2i2U$ftkloUS@ Sv2zmu0000%va literal 0 HcmV?d00001 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);