Better History display

This commit is contained in:
Sylvain Berfini 2011-11-03 12:04:45 +01:00
parent ec53982b3e
commit aa3522b74c
7 changed files with 242 additions and 197 deletions

View file

@ -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

View file

@ -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 ) 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 # As a memo, the config.h for zrtpcpp is generated using the command
# cmake -Denable-ccrtp=false submodules/externals/libzrtpcpp # cmake -Denable-ccrtp=false submodules/externals/libzrtpcpp

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

View file

@ -4,19 +4,22 @@
android:padding="6dip"> android:padding="6dip">
<FrameLayout <FrameLayout
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_marginRight="6dip" android:layout_alignParentBottom="true" android:layout_marginRight="6dip"
android:id="@+id/history_cell_icon"> android:id="@+id/history_cell_icon">
<ImageView android:id="@+id/history_cell_icon_contact"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_marginRight="6dip"
android:scaleType="centerInside"/>
<ImageView android:id="@+id/history_cell_icon_in" <ImageView android:id="@+id/history_cell_icon_in"
android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_gravity="right|bottom" android:layout_marginRight="6dip"
android:layout_alignParentBottom="true" android:layout_marginRight="6dip" android:src="@drawable/in_call_mini" android:scaleType="centerInside"/>
android:src="@drawable/in_call" android:scaleType="centerInside"/>
<ImageView android:id="@+id/history_cell_icon_out" <ImageView android:id="@+id/history_cell_icon_out"
android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_gravity="right|bottom" android:layout_marginRight="6dip"
android:layout_alignParentBottom="true" android:layout_marginRight="6dip" android:src="@drawable/out_call_mini" android:scaleType="centerInside"/>
android:src="@drawable/out_call" android:scaleType="centerInside"/>
</FrameLayout> </FrameLayout>
<TextView android:id="@+id/history_cell_second_line" <TextView android:id="@+id/history_cell_second_line"

View file

@ -1,173 +1,229 @@
/* /*
DialerActivity.java DialerActivity.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France Copyright (C) 2010 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
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone; package org.linphone;
import java.util.List; import java.util.List;
import org.linphone.core.CallDirection; import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCallLog; import org.linphone.core.LinphoneCallLog;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneProxyConfig; import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.Log; import org.linphone.core.Log;
import android.app.ListActivity; import android.app.ListActivity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.database.Cursor;
import android.view.LayoutInflater; import android.net.Uri;
import android.view.Menu; import android.os.Bundle;
import android.view.MenuInflater; import android.provider.ContactsContract;
import android.view.MenuItem; import android.view.LayoutInflater;
import android.view.View; import android.view.Menu;
import android.view.ViewGroup; import android.view.MenuInflater;
import android.widget.BaseAdapter; import android.view.MenuItem;
import android.widget.ImageView; import android.view.View;
import android.widget.ListView; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.BaseAdapter;
import android.widget.ImageView;
public class HistoryActivity extends ListActivity { import android.widget.ListView;
LayoutInflater mInflater; import android.widget.TextView;
@Override
public void onCreate(Bundle savedInstanceState) { public class HistoryActivity extends ListActivity {
super.onCreate(savedInstanceState); LayoutInflater mInflater;
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); Cursor mContacts;
} @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@Override mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
protected void onListItemClick(ListView l, View v, int position, long id) { mContacts = getContacts();
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(); @Override
if (lSecondLineView.getVisibility() == View.GONE) { protected void onListItemClick(ListView l, View v, int position, long id) {
// no display name super.onListItemClick(l, v, position, id);
parent.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null); TextView lFirstLineView = (TextView) v.findViewById(R.id.history_cell_first_line);
} else { TextView lSecondLineView = (TextView) v.findViewById(R.id.history_cell_second_line);
parent.setAddressAndGoToDialer( ContactPicked parent = (ContactPicked) getParent();
lSecondLineView.getText().toString(), if (lSecondLineView.getVisibility() == View.GONE) {
lFirstLineView.getText().toString(), // no display name
null); parent.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null);
} } else {
} parent.setAddressAndGoToDialer(
lSecondLineView.getText().toString(),
lFirstLineView.getText().toString(),
@Override null);
protected void onResume() { }
super.onResume(); }
setListAdapter(new CallHistoryAdapter(this));
}
@Override
@Override protected void onResume() {
public boolean onCreateOptionsMenu(Menu menu) { super.onResume();
// Inflate the currently selected menu XML resource. setListAdapter(new CallHistoryAdapter(this));
MenuInflater inflater = getMenuInflater(); }
inflater.inflate(R.menu.history_activity_menu, menu);
return true; @Override
} public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the currently selected menu XML resource.
@Override MenuInflater inflater = getMenuInflater();
public boolean onOptionsItemSelected(MenuItem item) { inflater.inflate(R.menu.history_activity_menu, menu);
switch (item.getItemId()) { return true;
case R.id.menu_clear_history: }
LinphoneManager.getLc().clearCallLogs();
setListAdapter(new CallHistoryAdapter(this)); @Override
public boolean onOptionsItemSelected(MenuItem item) {
break; switch (item.getItemId()) {
default: case R.id.menu_clear_history:
Log.e("Unknown menu item [",item,"]"); LinphoneManager.getLc().clearCallLogs();
break; setListAdapter(new CallHistoryAdapter(this));
}
break;
return false; default:
} Log.e("Unknown menu item [",item,"]");
break;
}
class CallHistoryAdapter extends BaseAdapter {
final List<LinphoneCallLog> mLogs; return false;
}
@SuppressWarnings("unchecked")
CallHistoryAdapter(Context aContext) { /**
mLogs = LinphoneManager.getLc().getCallLogs(); * Obtains the contact list for the currently selected account.
} *
public int getCount() { * @return A cursor for for accessing the contact list.
return mLogs.size(); */
} private Cursor getContacts()
{
public Object getItem(int position) { // Run query
return position; Uri uri = ContactsContract.Data.CONTENT_URI;
} String[] projection = new String[] {
ContactsContract.Data._ID,
public long getItemId(int position) { ContactsContract.Data.DISPLAY_NAME,
ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS,
return position; ContactsContract.CommonDataKinds.Phone.NUMBER
} };
String selection =
public View getView(int position, View convertView, ViewGroup parent) { ContactsContract.Data.MIMETYPE+" ='"
View lView=null; +ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE+"'";
if (convertView !=null) { String[] selectionArgs = null;
lView = convertView; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
} else {
lView = mInflater.inflate(R.layout.history_cell, parent,false); return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
}
}
LinphoneCallLog lLog = mLogs.get(position); private String getContactNameIfExist(String sipUri)
LinphoneAddress lAddress; {
TextView lFirstLineView = (TextView) lView.findViewById(R.id.history_cell_first_line); String contactName = null;
TextView lSecondLineView = (TextView) lView.findViewById(R.id.history_cell_second_line); if (mContacts != null && mContacts.moveToFirst())
ImageView lDirectionImageIn = (ImageView) lView.findViewById(R.id.history_cell_icon_in); {
ImageView lDirectionImageOut = (ImageView) lView.findViewById(R.id.history_cell_icon_out); int displayNameColumnIndex = mContacts.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
int sipAdressColumnIndex = mContacts.getColumnIndex(ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS);
if (lLog.getDirection() == CallDirection.Incoming) { int phoneNumberColumnIndex = mContacts.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
lAddress = lLog.getFrom(); do
lDirectionImageIn.setVisibility(View.VISIBLE); {
lDirectionImageOut.setVisibility(View.GONE); String sipAdress = mContacts.getString(sipAdressColumnIndex);
String phoneNumber = mContacts.getString(phoneNumberColumnIndex);
} else { if (sipUri.toLowerCase().contains(sipAdress.toLowerCase()) || sipUri.toLowerCase().contains(phoneNumber.toLowerCase()))
lAddress = lLog.getTo(); contactName = mContacts.getString(displayNameColumnIndex);
lDirectionImageIn.setVisibility(View.GONE); }
lDirectionImageOut.setVisibility(View.VISIBLE); while (contactName == null && mContacts.moveToNext());
} }
LinphoneCore lc = LinphoneManager.getLc(); return contactName;
LinphoneProxyConfig lProxyConfig = lc.getDefaultProxyConfig(); }
String lDetailedName=null;
String lDisplayName = lAddress.getDisplayName(); class CallHistoryAdapter extends BaseAdapter {
final List<LinphoneCallLog> mLogs;
if (lProxyConfig != null && lProxyConfig.getDomain().equals(lAddress.getDomain())) {
lDetailedName = lAddress.getUserName(); @SuppressWarnings("unchecked")
} else { CallHistoryAdapter(Context aContext) {
lDetailedName = lAddress.asStringUriOnly(); mLogs = LinphoneManager.getLc().getCallLogs();
} }
if (lDisplayName == null) { public int getCount() {
lFirstLineView.setText(lDetailedName); return mLogs.size();
lSecondLineView.setVisibility(View.GONE); }
} else {
lFirstLineView.setText(lDisplayName); public Object getItem(int position) {
lSecondLineView.setText(lDetailedName); return position;
lSecondLineView.setVisibility(View.VISIBLE); }
}
public long getItemId(int position) {
return lView;
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;
}
}
}