From aa3522b74cbbe8ae41db15fea4bf81b3585ee6e6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 3 Nov 2011 12:04:45 +0100 Subject: [PATCH] Better History display --- default.properties | 13 - prepare_sources.sh | 1 - res/drawable/in_call_mini.png | Bin 0 -> 807 bytes res/drawable/out_call.png | Bin 3260 -> 2900 bytes res/drawable/out_call_mini.png | Bin 0 -> 852 bytes res/layout/history_cell.xml | 23 +- src/org/linphone/HistoryActivity.java | 402 +++++++++++++++----------- 7 files changed, 242 insertions(+), 197 deletions(-) delete mode 100644 default.properties create mode 100644 res/drawable/in_call_mini.png create mode 100644 res/drawable/out_call_mini.png diff --git a/default.properties b/default.properties deleted file mode 100644 index e735ffa56..000000000 --- a/default.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Indicates whether an apk should be generated for each density. -split.density=false -# Project target. -target=android-13 diff --git a/prepare_sources.sh b/prepare_sources.sh index 0546614cd..70b5b4357 100755 --- a/prepare_sources.sh +++ b/prepare_sources.sh @@ -15,6 +15,5 @@ cd $topdir/submodules/externals/build/libvpx && ./asm_conversion.sh && cp *.asm cd $topdir/submodules/mssilk && ./autogen.sh && ./configure MEDIASTREAMER_CFLAGS=" " MEDIASTREAMER_LIBS=" " && cd sdk && make extract-sources || ( echo "SILK audio plugin prepare state failed." ; exit 1 ) - # As a memo, the config.h for zrtpcpp is generated using the command # cmake -Denable-ccrtp=false submodules/externals/libzrtpcpp diff --git a/res/drawable/in_call_mini.png b/res/drawable/in_call_mini.png new file mode 100644 index 0000000000000000000000000000000000000000..e307d23e35827e334d61282146b63ee687926323 GIT binary patch literal 807 zcmV+?1K9kDP)X1^@s6)5{gA00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L03}}l03}}miJgBf00007bV*G`2ipo9 z3^^&Gep+|{00O5;L_t(I%axTek5p9{hM)J`%dWeIFgMW5ghHr{2@ztUP}9*E3n~)} zD`yHT6aRugV79QZprGX!7!oiPQb=M15~3yqxR4lU0-|JQ&Ur1)z3iRcyJR`ZE#}Pq zo_W9Tea{)uS>xg0G~)LafH`m(C;`D2JN5iZyI<~k@7M<7b8lfmDG>xk5QTQ1GQibW z|L`ouQ{CddFl4AKOjC#`oxvrd5R`}`(musyUmL3g1S6Y-NCcum7+EC1J!9yF*~S*h z5NRP9oT2KSWiKq+*dXV!1PvsQ!MN9-vd^h#vJykY2)%AE8CIwl*Q+eqV4O>=;!@HRcXqA|tuojKfetCEUy7|gFax_H5xDPfS4!)Lju1WrJ)|44J2O%J$Ku!cg ztNhdPaPXca*?w69mkk%HrLh7>BVK}v_FUSpgNt+KRx%&Dh3(Yy ze`TMT9kK2lwQZ9y$tj=9&hsENAnRfaT7v;h>-kJ(^w);<>$dIWPRqH~M@rl(m&p2T zTF-v$)`z`Wnbz}K=JeA|>;9IV+?-2`zXdlpm&p2ZTF)E%HQMC_rs5Kc@ lm%bVeJRViwH?AM}?*GBKlZsw;dUXH*002ovPDHLkV1h*{bCCc5 literal 0 HcmV?d00001 diff --git a/res/drawable/out_call.png b/res/drawable/out_call.png index 7fef2b4ae619f9febba445900f1f7fbd8f3f6461..80640c31a2d87d7430543db6b1f5cd25e85488d4 100644 GIT binary patch delta 2873 zcmV-93&!-k8Ppb#Bpd;AQb$4nuFf3k00006VoOIv0RI600RN!9r<0K}7=H(JNliru z+X@^EIS+Gl--Q4G3e-tNK~#9!?VMd~99J2JpEF)N{#Z8*n z&YwU{P)kS}B@KvD38@(&QMf=O5AV<7YKRJlM zD)6nv`GtRHWqu+nVA-y-3HUXzMLGQkU}kZC;e#y9(aH!=1Hd&6D1b@eZQFIa{ts3W zs2<>#z}+D)nFfAlyUw~h8Z6s&+JQHL{V^{+2E1asPRkt$mhCz@;D0q>HZUpktR4k^ zV7rdE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G`2ipo9 z3^@ekp#}{A00PuWL_t(I%bk_Yi&RGx#m~8~T6>bt&`;3;`wg16ay=_Mt=$`7Wv4>F+e5Qm-P%$2&rbaCFISd?I0o{V)D4HinK^LZ z0ZPK(WvBXZHD)74&31Jo)b#x~7hcoMPy~Y&Lt!R=-%GpN^kfSX~@yhN2*fFzOjr%m0I6s$sZ(+4awJJ@0pW`-*0}^|PGqPdCXlb10iNP}P*Pp=tS>yaeGj0r*tZYjgLUF>&z zmqvrIzKDgiSW*UL*Ib|r9sxH20wldt^kK7O;W4YAKtomskU}J2g`iFBHivnJjX}r^ z^|TqJ4X1G~5~ z0Cxvtu?CKuJOQKQ!fY4`kPez5da5@}22<`a-JKL*_U^4=o4p?EV3GztEHHn+wZ*%m e@fg1yU-ci??}m}Gj0+b40000 + + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="right|bottom" android:layout_marginRight="6dip" + android:src="@drawable/in_call_mini" android:scaleType="centerInside"/> + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="right|bottom" android:layout_marginRight="6dip" + android:src="@drawable/out_call_mini" android:scaleType="centerInside"/> mLogs; - - @SuppressWarnings("unchecked") - CallHistoryAdapter(Context aContext) { - mLogs = LinphoneManager.getLc().getCallLogs(); - } - public int getCount() { - return mLogs.size(); - } - - public Object getItem(int position) { - return position; - } - - public long getItemId(int position) { - - return position; - } - - public View getView(int position, View convertView, ViewGroup parent) { - View lView=null; - if (convertView !=null) { - lView = convertView; - } else { - lView = mInflater.inflate(R.layout.history_cell, parent,false); - - } - LinphoneCallLog lLog = mLogs.get(position); - LinphoneAddress lAddress; - TextView lFirstLineView = (TextView) lView.findViewById(R.id.history_cell_first_line); - TextView lSecondLineView = (TextView) lView.findViewById(R.id.history_cell_second_line); - ImageView lDirectionImageIn = (ImageView) lView.findViewById(R.id.history_cell_icon_in); - ImageView lDirectionImageOut = (ImageView) lView.findViewById(R.id.history_cell_icon_out); - - if (lLog.getDirection() == CallDirection.Incoming) { - lAddress = lLog.getFrom(); - lDirectionImageIn.setVisibility(View.VISIBLE); - lDirectionImageOut.setVisibility(View.GONE); - - } else { - lAddress = lLog.getTo(); - lDirectionImageIn.setVisibility(View.GONE); - lDirectionImageOut.setVisibility(View.VISIBLE); - } - LinphoneCore lc = LinphoneManager.getLc(); - LinphoneProxyConfig lProxyConfig = lc.getDefaultProxyConfig(); - String lDetailedName=null; - String lDisplayName = lAddress.getDisplayName(); - - if (lProxyConfig != null && lProxyConfig.getDomain().equals(lAddress.getDomain())) { - lDetailedName = lAddress.getUserName(); - } else { - lDetailedName = lAddress.asStringUriOnly(); - } - if (lDisplayName == null) { - lFirstLineView.setText(lDetailedName); - lSecondLineView.setVisibility(View.GONE); - } else { - lFirstLineView.setText(lDisplayName); - lSecondLineView.setText(lDetailedName); - lSecondLineView.setVisibility(View.VISIBLE); - } - - return lView; - - } - - } -} +/* +DialerActivity.java +Copyright (C) 2010 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 +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +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. +*/ +package org.linphone; + + + +import java.util.List; + +import org.linphone.core.CallDirection; +import org.linphone.core.LinphoneAddress; +import org.linphone.core.LinphoneCallLog; +import org.linphone.core.LinphoneCore; +import org.linphone.core.LinphoneProxyConfig; +import org.linphone.core.Log; + +import android.app.ListActivity; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; + +public class HistoryActivity extends ListActivity { + LayoutInflater mInflater; + Cursor mContacts; + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mContacts = getContacts(); + } + + + @Override + protected void onListItemClick(ListView l, View v, int position, long id) { + super.onListItemClick(l, v, position, id); + TextView lFirstLineView = (TextView) v.findViewById(R.id.history_cell_first_line); + TextView lSecondLineView = (TextView) v.findViewById(R.id.history_cell_second_line); + ContactPicked parent = (ContactPicked) getParent(); + if (lSecondLineView.getVisibility() == View.GONE) { + // no display name + parent.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null); + } else { + parent.setAddressAndGoToDialer( + lSecondLineView.getText().toString(), + lFirstLineView.getText().toString(), + null); + } + } + + + @Override + protected void onResume() { + super.onResume(); + setListAdapter(new CallHistoryAdapter(this)); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the currently selected menu XML resource. + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.history_activity_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_clear_history: + LinphoneManager.getLc().clearCallLogs(); + setListAdapter(new CallHistoryAdapter(this)); + + break; + default: + Log.e("Unknown menu item [",item,"]"); + break; + } + + return false; + } + + /** + * Obtains the contact list for the currently selected account. + * + * @return A cursor for for accessing the contact list. + */ + private Cursor getContacts() + { + // Run query + Uri uri = ContactsContract.Data.CONTENT_URI; + String[] projection = new String[] { + ContactsContract.Data._ID, + ContactsContract.Data.DISPLAY_NAME, + ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS, + ContactsContract.CommonDataKinds.Phone.NUMBER + }; + String selection = + ContactsContract.Data.MIMETYPE+" ='" + +ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE+"'"; + String[] selectionArgs = null; + String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; + + return managedQuery(uri, projection, selection, selectionArgs, sortOrder); + } + + private String getContactNameIfExist(String sipUri) + { + String contactName = null; + if (mContacts != null && mContacts.moveToFirst()) + { + int displayNameColumnIndex = mContacts.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); + int sipAdressColumnIndex = mContacts.getColumnIndex(ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS); + int phoneNumberColumnIndex = mContacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); + do + { + String sipAdress = mContacts.getString(sipAdressColumnIndex); + String phoneNumber = mContacts.getString(phoneNumberColumnIndex); + if (sipUri.toLowerCase().contains(sipAdress.toLowerCase()) || sipUri.toLowerCase().contains(phoneNumber.toLowerCase())) + contactName = mContacts.getString(displayNameColumnIndex); + } + while (contactName == null && mContacts.moveToNext()); + } + return contactName; + } + + class CallHistoryAdapter extends BaseAdapter { + final List mLogs; + + @SuppressWarnings("unchecked") + CallHistoryAdapter(Context aContext) { + mLogs = LinphoneManager.getLc().getCallLogs(); + } + public int getCount() { + return mLogs.size(); + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + View lView=null; + if (convertView !=null) { + lView = convertView; + } else { + lView = mInflater.inflate(R.layout.history_cell, parent,false); + + } + LinphoneCallLog lLog = mLogs.get(position); + LinphoneAddress lAddress; + TextView lFirstLineView = (TextView) lView.findViewById(R.id.history_cell_first_line); + TextView lSecondLineView = (TextView) lView.findViewById(R.id.history_cell_second_line); + ImageView lDirectionImageIn = (ImageView) lView.findViewById(R.id.history_cell_icon_in); + ImageView lDirectionImageOut = (ImageView) lView.findViewById(R.id.history_cell_icon_out); + ImageView lContactPicture = (ImageView) lView.findViewById(R.id.history_cell_icon_contact); + + if (lLog.getDirection() == CallDirection.Incoming) { + lAddress = lLog.getFrom(); + lDirectionImageIn.setVisibility(View.VISIBLE); + lDirectionImageOut.setVisibility(View.GONE); + + } else { + lAddress = lLog.getTo(); + lDirectionImageIn.setVisibility(View.GONE); + lDirectionImageOut.setVisibility(View.VISIBLE); + } + + Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver()); + LinphoneUtils.setImagePictureFromUri(lView.getContext(), lContactPicture, uri, R.drawable.unknown_person); + + LinphoneCore lc = LinphoneManager.getLc(); + LinphoneProxyConfig lProxyConfig = lc.getDefaultProxyConfig(); + String lDetailedName=null; + String lDisplayName = lAddress.getDisplayName(); + if (lDisplayName == null) + lDisplayName = getContactNameIfExist(lAddress.asStringUriOnly()); + + if (lProxyConfig != null && lProxyConfig.getDomain().equals(lAddress.getDomain())) { + lDetailedName = lAddress.getUserName(); + } else { + lDetailedName = lAddress.asStringUriOnly(); + } + + if (lDisplayName == null) { + lFirstLineView.setText(lDetailedName); + lSecondLineView.setVisibility(View.GONE); + } else { + lFirstLineView.setText(lDisplayName); + lSecondLineView.setText(lDetailedName); + lSecondLineView.setVisibility(View.VISIBLE); + } + + return lView; + + } + + } +}