Read contact picture. (not integrated in incall activity).
This commit is contained in:
parent
6d530bd16f
commit
cb0714bef7
8 changed files with 307 additions and 190 deletions
172
src/org/linphone/AbstractContactPickerActivity.java
Normal file
172
src/org/linphone/AbstractContactPickerActivity.java
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
ContactPickerActivity.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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FilterQueryProvider;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
|
||||
/**
|
||||
* Activity for retrieving a phone number / SIP address to call.
|
||||
* <br />
|
||||
*
|
||||
* The cinematic is:
|
||||
* <ul>
|
||||
* <li>Select contact (either through native or custom way)</li>
|
||||
* <li>Select phone number or SIP address
|
||||
* <li>Back to dialer</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Guillaume Beraudo
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractContactPickerActivity extends Activity implements FilterQueryProvider {
|
||||
|
||||
private ListView mContactList;
|
||||
protected EditText mcontactFilter;
|
||||
|
||||
private SimpleCursorAdapter adapter;
|
||||
protected boolean useNativePicker;
|
||||
|
||||
protected final String col_display_name = "display_name";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
useNativePicker = getResources().getBoolean(R.bool.use_android_contact_picker);
|
||||
|
||||
if (!useNativePicker) {
|
||||
setContentView(R.layout.contact_picker);
|
||||
createCustomPicker();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void createCustomPicker() {
|
||||
mContactList = (ListView) findViewById(R.id.contactList);
|
||||
|
||||
mcontactFilter = (EditText) findViewById(R.id.contactFilter);
|
||||
mcontactFilter.addTextChangedListener(new TextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int b, int c) {}
|
||||
public void beforeTextChanged(CharSequence s, int st, int c, int a) {}
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
adapter.runQueryOnBackgroundThread(s);
|
||||
adapter.getFilter().filter(s.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Populate the contact list
|
||||
String[] from = new String[] {col_display_name};
|
||||
int[] to = new int[] {android.R.id.text1};
|
||||
int layout = android.R.layout.simple_list_item_1;
|
||||
adapter = new SimpleCursorAdapter(this, layout, runQuery(null), from, to);
|
||||
adapter.setFilterQueryProvider(this);
|
||||
mContactList.setAdapter(adapter);
|
||||
|
||||
mContactList.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final CharSequence contactName = ((TextView) view.findViewById(android.R.id.text1)).getText();
|
||||
choosePhoneNumberAndDial(contactName, String.valueOf(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void choosePhoneNumberAndDial(final CharSequence contactName, final String id) {
|
||||
List<String> phones = extractPhones(id);
|
||||
phones.addAll(extractSipNumbers(id));
|
||||
|
||||
switch (phones.size()) {
|
||||
case 0:
|
||||
String msg = String.format(getString(R.string.no_phone_numbers), contactName);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 1:
|
||||
returnSelectedValues(phones.get(0), contactName.toString(), getPhotoUri(id));
|
||||
break;
|
||||
default:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
final ArrayAdapter<String> pAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_dropdown_item_1line, phones);
|
||||
|
||||
builder.setTitle(String.format(getString(R.string.title_numbers_dialog),contactName));
|
||||
builder.setAdapter(pAdapter, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
returnSelectedValues(pAdapter.getItem(which), contactName.toString(),getPhotoUri(id));
|
||||
}
|
||||
});
|
||||
builder.setCancelable(true);
|
||||
builder.setNeutralButton("cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void returnSelectedValues(String number, String name, Uri photo) {
|
||||
/* if (getCallingActivity() != null) {
|
||||
setResult(RESULT_OK, new Intent()
|
||||
.putExtra(Intent.EXTRA_PHONE_NUMBER, number)
|
||||
.putExtra(EXTRA_CONTACT_NAME, name));
|
||||
finish();
|
||||
}*/
|
||||
|
||||
LinphoneActivity.setAddressAndGoToDialer(number, name, photo);
|
||||
}
|
||||
|
||||
|
||||
protected abstract List<String> extractPhones(String id);
|
||||
protected abstract Uri getPhotoUri(String id);
|
||||
|
||||
// Hook
|
||||
protected List<String> extractSipNumbers(String id) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract Cursor runQuery(CharSequence constraint);
|
||||
|
||||
}
|
|
@ -21,27 +21,13 @@ package org.linphone;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.Editable;
|
||||
import android.provider.ContactsContract.Contacts;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FilterQueryProvider;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -58,148 +44,74 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||
* @author Guillaume Beraudo
|
||||
*
|
||||
*/
|
||||
public class ContactPickerActivityNew extends Activity implements FilterQueryProvider {
|
||||
public class ContactPickerActivityNew extends AbstractContactPickerActivity {
|
||||
|
||||
private ListView mContactList;
|
||||
private EditText mcontactFilter;
|
||||
|
||||
private SimpleCursorAdapter adapter;
|
||||
private boolean useNativePicker;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
useNativePicker = getResources().getBoolean(R.bool.use_android_contact_picker);
|
||||
|
||||
if (!useNativePicker) {
|
||||
setContentView(R.layout.contact_picker);
|
||||
createPicker();
|
||||
public Uri getPhotoUri(String id) {
|
||||
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, Long.parseLong(id));
|
||||
Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
|
||||
if (photoUri == null) {
|
||||
return null;
|
||||
}
|
||||
Cursor cursor = getContentResolver().query(photoUri,
|
||||
new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
|
||||
try {
|
||||
if (cursor == null || !cursor.moveToNext()) {
|
||||
return null;
|
||||
}
|
||||
byte[] data = cursor.getBlob(0);
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
return photoUri;
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void createPicker() {
|
||||
mContactList = (ListView) findViewById(R.id.contactList);
|
||||
|
||||
mcontactFilter = (EditText) findViewById(R.id.contactFilter);
|
||||
mcontactFilter.addTextChangedListener(new TextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int b, int c) {}
|
||||
public void beforeTextChanged(CharSequence s, int st, int c, int a) {}
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
adapter.runQueryOnBackgroundThread(s);
|
||||
adapter.getFilter().filter(s.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Populate the contact list
|
||||
String[] from = new String[] {ContactsContract.Data.DISPLAY_NAME};
|
||||
int[] to = new int[] {android.R.id.text1};
|
||||
int layout = android.R.layout.simple_list_item_1;
|
||||
adapter = new SimpleCursorAdapter(this, layout, runQuery(null), from, to);
|
||||
adapter.setFilterQueryProvider(this);
|
||||
mContactList.setAdapter(adapter);
|
||||
|
||||
mContactList.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final CharSequence contactName = ((TextView) view.findViewById(android.R.id.text1)).getText();
|
||||
choosePhoneNumberAndDial(contactName, String.valueOf(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void choosePhoneNumberAndDial(final CharSequence contactName, final String id) {
|
||||
List<String> phones = extractPhones(id);
|
||||
phones.addAll(extractSipNumbers(id));
|
||||
|
||||
switch (phones.size()) {
|
||||
case 0:
|
||||
String msg = String.format(getString(R.string.no_phone_numbers), contactName);
|
||||
Toast.makeText(ContactPickerActivityNew.this, msg, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 1:
|
||||
returnSelectedValues(phones.get(0), contactName.toString());
|
||||
break;
|
||||
default:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ContactPickerActivityNew.this);
|
||||
|
||||
final ArrayAdapter<String> pAdapter = new ArrayAdapter<String>(ContactPickerActivityNew.this,
|
||||
android.R.layout.simple_dropdown_item_1line, phones);
|
||||
|
||||
builder.setTitle(String.format(getString(R.string.title_numbers_dialog),contactName));
|
||||
builder.setAdapter(pAdapter, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
returnSelectedValues(pAdapter.getItem(which), contactName.toString());
|
||||
}
|
||||
});
|
||||
builder.setCancelable(true);
|
||||
builder.setNeutralButton("cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void returnSelectedValues(String number, String name) {
|
||||
/* if (getCallingActivity() != null) {
|
||||
setResult(RESULT_OK, new Intent()
|
||||
.putExtra(Intent.EXTRA_PHONE_NUMBER, number)
|
||||
.putExtra(EXTRA_CONTACT_NAME, name));
|
||||
finish();
|
||||
}*/
|
||||
|
||||
LinphoneActivity.setAddressAndGoToDialer(number, name);
|
||||
}
|
||||
|
||||
|
||||
private List<String> extractPhones(String id) {
|
||||
protected List<String> extractPhones(String id) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
|
||||
String selection = ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?";
|
||||
String[] selArgs = new String[] {id};
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
|
||||
int nbId = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
|
||||
int nbId = c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
|
||||
|
||||
while (c.moveToNext()) {
|
||||
list.add(c.getString(nbId));
|
||||
}
|
||||
while (c.moveToNext()) {
|
||||
list.add(c.getString(nbId));
|
||||
}
|
||||
|
||||
c.close();
|
||||
c.close();
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> extractSipNumbers(String id) {
|
||||
protected List<String> extractSipNumbers(String id) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Uri uri = ContactsContract.Data.CONTENT_URI;
|
||||
String selection = new StringBuilder()
|
||||
.append(ContactsContract.Data.CONTACT_ID).append(" = ? AND ")
|
||||
.append(ContactsContract.Data.MIMETYPE).append(" = ? ")
|
||||
.append(" AND lower(")
|
||||
.append(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL)
|
||||
.append(") = 'sip'").toString();
|
||||
.append(ContactsContract.Data.CONTACT_ID).append(" = ? AND ")
|
||||
.append(ContactsContract.Data.MIMETYPE).append(" = ? ")
|
||||
.append(" AND lower(")
|
||||
.append(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL)
|
||||
.append(") = 'sip'").toString();
|
||||
String[] selArgs = new String[] {id, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE};
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
|
||||
int nbId = c.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA);
|
||||
int nbId = c.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA);
|
||||
|
||||
while (c.moveToNext()) {
|
||||
list.add("sip:" + c.getString(nbId));
|
||||
}
|
||||
while (c.moveToNext()) {
|
||||
list.add("sip:" + c.getString(nbId));
|
||||
}
|
||||
|
||||
c.close();
|
||||
c.close();
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -217,10 +129,10 @@ public class ContactPickerActivityNew extends Activity implements FilterQueryPro
|
|||
// If using native picker
|
||||
if (reqCode == 0) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
String id = intent.getData().getLastPathSegment();
|
||||
String contactName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
||||
if (contactName == null)
|
||||
contactName = retrieveContactName(id);
|
||||
String id = intent.getData().getLastPathSegment();
|
||||
String contactName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
||||
if (contactName == null)
|
||||
contactName = retrieveContactName(id);
|
||||
choosePhoneNumberAndDial(contactName, id);
|
||||
}
|
||||
}
|
||||
|
@ -233,38 +145,38 @@ public class ContactPickerActivityNew extends Activity implements FilterQueryPro
|
|||
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
|
||||
String selection = ContactsContract.CommonDataKinds.Phone._ID + " = ?";
|
||||
String[] selArgs = new String[] {id};
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
Cursor c = this.getContentResolver().query(uri, null, selection, selArgs, null);
|
||||
|
||||
String name = "";
|
||||
if (c.moveToFirst()) {
|
||||
name = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
|
||||
}
|
||||
c.close();
|
||||
String name = "";
|
||||
if (c.moveToFirst()) {
|
||||
name = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
|
||||
}
|
||||
c.close();
|
||||
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Cursor runQuery(CharSequence constraint) {
|
||||
// Run query
|
||||
Uri uri = ContactsContract.Contacts.CONTENT_URI;
|
||||
String[] projection = new String[] {
|
||||
ContactsContract.Contacts._ID,
|
||||
ContactsContract.Contacts.DISPLAY_NAME
|
||||
};
|
||||
String selection =
|
||||
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1' and "
|
||||
+ ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
|
||||
String[] selectionArgs = null;
|
||||
if (!TextUtils.isEmpty(constraint)) {
|
||||
// FIXME absolutely unsecure
|
||||
selection += " and " + ContactsContract.Contacts.DISPLAY_NAME + " ilike '%"+mcontactFilter.getText()+"%'";
|
||||
}
|
||||
Uri uri = ContactsContract.Contacts.CONTENT_URI;
|
||||
String[] projection = new String[] {
|
||||
ContactsContract.Contacts._ID,
|
||||
ContactsContract.Contacts.DISPLAY_NAME
|
||||
};
|
||||
String selection =
|
||||
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1' and "
|
||||
+ ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";
|
||||
String[] selectionArgs = null;
|
||||
if (!TextUtils.isEmpty(constraint)) {
|
||||
// FIXME SQL injection - Android doesn't accept '?' in like queries
|
||||
selection += " and " + ContactsContract.Contacts.DISPLAY_NAME + " like '%"+mcontactFilter.getText()+"%'";
|
||||
}
|
||||
|
||||
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
|
||||
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
|
||||
|
||||
return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
|
||||
return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,11 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
package org.linphone;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Contacts;
|
||||
import android.provider.Contacts.People;
|
||||
import android.provider.Contacts.Photos;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ContactPickerActivityOld extends Activity {
|
||||
|
@ -45,11 +48,27 @@ public class ContactPickerActivityOld extends Activity {
|
|||
|
||||
}
|
||||
|
||||
private Uri getPhotoUri(Uri photoUri) {
|
||||
Cursor cursor = getContentResolver().query(photoUri, new String[]{Photos.DATA}, null, null, null);
|
||||
try {
|
||||
if (cursor == null || !cursor.moveToNext()) {
|
||||
return null;
|
||||
}
|
||||
byte[] data = cursor.getBlob(0);
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
return photoUri;
|
||||
} finally {
|
||||
if (cursor != null) cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode,
|
||||
Intent data) {
|
||||
if (requestCode == PICK_CONTACT_REQUEST) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
String lColumns[] = new String[] { People.NAME, People.NUMBER };
|
||||
String lColumns[] = new String[] { People._ID, People.NAME, People.NUMBER };
|
||||
|
||||
Cursor lCur = managedQuery(data.getData(), lColumns, // Which columns to return
|
||||
null, // WHERE clause; which rows to return(all rows)
|
||||
|
@ -58,12 +77,14 @@ public class ContactPickerActivityOld extends Activity {
|
|||
|
||||
);
|
||||
if (lCur.moveToFirst()) {
|
||||
String lName = null;
|
||||
String lPhoneNo = null;
|
||||
// Get the field values
|
||||
lName = lCur.getString(lCur.getColumnIndex(People.NAME));
|
||||
lPhoneNo = lCur.getString(lCur.getColumnIndex(People.NUMBER));
|
||||
DialerActivity.instance().setContactAddress(lPhoneNo, lName);
|
||||
String lName = lCur.getString(lCur.getColumnIndex(People.NAME));
|
||||
String lPhoneNo = lCur.getString(lCur.getColumnIndex(People.NUMBER));
|
||||
long id = lCur.getLong(lCur.getColumnIndex(People._ID));
|
||||
Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, id);
|
||||
Uri potentialPictureUri = Uri.withAppendedPath(personUri, Contacts.Photos.CONTENT_DIRECTORY);
|
||||
Uri pictureUri = getPhotoUri(potentialPictureUri);
|
||||
// FIXME surprisingly all this picture stuff doesn't seem to work
|
||||
DialerActivity.instance().setContactAddress(lPhoneNo, lName, pictureUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -220,7 +221,8 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
|
|||
if (!mWakeLock.isHeld()) mWakeLock.acquire();
|
||||
|
||||
if (useIncallActivity) {
|
||||
LinphoneActivity.instance().startIncallActivity(mDisplayNameView.getText());
|
||||
LinphoneActivity.instance().startIncallActivity(
|
||||
mDisplayNameView.getText(), mAddress.getPictureUri());
|
||||
} else {
|
||||
loadMicAndSpeakerUiStateFromManager();
|
||||
mCallControlRow.setVisibility(View.GONE);
|
||||
|
@ -346,9 +348,10 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
|
|||
}
|
||||
|
||||
|
||||
public void setContactAddress(String aContact,String aDisplayName) {
|
||||
public void setContactAddress(String aContact,String aDisplayName, Uri photo) {
|
||||
mAddress.setText(aContact);
|
||||
mAddress.setDisplayedName(aDisplayName);
|
||||
mAddress.setPictureUri(photo);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,11 +59,12 @@ public class HistoryActivity extends ListActivity {
|
|||
TextView lSecondLineView = (TextView) v.findViewById(R.id.history_cell_second_line);
|
||||
if (lSecondLineView.getVisibility() == View.GONE) {
|
||||
// no display name
|
||||
LinphoneActivity.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null);
|
||||
LinphoneActivity.setAddressAndGoToDialer(lFirstLineView.getText().toString(), null, null);
|
||||
} else {
|
||||
LinphoneActivity.setAddressAndGoToDialer(
|
||||
lSecondLineView.getText().toString(),
|
||||
lFirstLineView.getText().toString());
|
||||
lFirstLineView.getText().toString(),
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.widget.TextView;
|
|||
public class IncallActivity extends SoftVolumeActivity implements OnClickListener {
|
||||
|
||||
public static final String CONTACT_KEY = "contact";
|
||||
public static final String PICTURE_URI_KEY = "picture_uri";
|
||||
private View numpadClose;
|
||||
private View numpadShow;
|
||||
private View numpad;
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.hardware.Sensor;
|
|||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -214,7 +215,7 @@ public class LinphoneActivity extends TabActivity {
|
|||
gotToDialer();
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.use_incall_activity)) {
|
||||
startIncallActivity(LinphoneManager.getInstance().extractADisplayName());
|
||||
startIncallActivity(LinphoneManager.getInstance().extractADisplayName(), null);
|
||||
} else {
|
||||
// TODO
|
||||
Log.e(TAG, "Not handled case: recreation while in call and not using incall activity");
|
||||
|
@ -423,8 +424,8 @@ public class LinphoneActivity extends TabActivity {
|
|||
builder.create().show();
|
||||
}
|
||||
|
||||
static void setAddressAndGoToDialer(String number, String name) {
|
||||
DialerActivity.instance().setContactAddress(number, name);
|
||||
static void setAddressAndGoToDialer(String number, String name, Uri photo) {
|
||||
DialerActivity.instance().setContactAddress(number, name, photo);
|
||||
instance.gotToDialer();
|
||||
}
|
||||
|
||||
|
@ -441,11 +442,12 @@ public class LinphoneActivity extends TabActivity {
|
|||
getTabHost().addTab(spec);
|
||||
}
|
||||
|
||||
public void startIncallActivity(CharSequence callerName) {
|
||||
startActivityForResult(
|
||||
new Intent().setClass(this, IncallActivity.class)
|
||||
.putExtra(IncallActivity.CONTACT_KEY, callerName),
|
||||
INCALL_ACTIVITY);
|
||||
public void startIncallActivity(CharSequence callerName, Uri pictureUri) {
|
||||
Intent intent = new Intent().setClass(this, IncallActivity.class)
|
||||
.putExtra(IncallActivity.CONTACT_KEY, callerName);
|
||||
if (pictureUri != null)
|
||||
intent.putExtra(IncallActivity.PICTURE_URI_KEY, pictureUri.toString());
|
||||
startActivityForResult(intent, INCALL_ACTIVITY);
|
||||
}
|
||||
|
||||
public void closeIncallActivity() {
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone.ui;
|
|||
import org.linphone.LinphoneManager.AddressType;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.EditText;
|
||||
|
||||
|
@ -31,6 +32,10 @@ import android.widget.EditText;
|
|||
public class AddressText extends EditText implements AddressType {
|
||||
|
||||
private String displayedName;
|
||||
private Uri pictureUri;
|
||||
public void setPictureUri(Uri uri) {pictureUri = uri;}
|
||||
public Uri getPictureUri() {return pictureUri;}
|
||||
|
||||
|
||||
public AddressText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
@ -57,8 +62,8 @@ public class AddressText extends EditText implements AddressType {
|
|||
protected void onTextChanged(CharSequence text, int start, int before,
|
||||
int after) {
|
||||
clearDisplayedName();
|
||||
pictureUri=null;
|
||||
super.onTextChanged(text, start, before, after);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue