mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
fix to show/return individual phone numbers. Still todo: warn rather
than drop numbers not flagged as mobile.
This commit is contained in:
parent
e703685021
commit
522fd29b44
1 changed files with 25 additions and 32 deletions
|
@ -104,6 +104,7 @@ public class SMSInviteActivity extends InviteActivity implements TextWatcher {
|
||||||
{
|
{
|
||||||
Intent intent = new Intent( Intent.ACTION_PICK,
|
Intent intent = new Intent( Intent.ACTION_PICK,
|
||||||
ContactsContract.Contacts.CONTENT_URI );
|
ContactsContract.Contacts.CONTENT_URI );
|
||||||
|
intent.setType( Phone.CONTENT_TYPE );
|
||||||
startActivityForResult( intent, GET_CONTACT );
|
startActivityForResult( intent, GET_CONTACT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,43 +160,35 @@ public class SMSInviteActivity extends InviteActivity implements TextWatcher {
|
||||||
private void addPhoneNumbers( Intent intent )
|
private void addPhoneNumbers( Intent intent )
|
||||||
{
|
{
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
Cursor cursor = managedQuery( data, null, null, null, null );
|
Cursor cursor = managedQuery( data,
|
||||||
|
new String[] { Phone.DISPLAY_NAME,
|
||||||
|
Phone.NUMBER,
|
||||||
|
Phone.TYPE },
|
||||||
|
null, null, null );
|
||||||
if ( cursor.moveToFirst() ) {
|
if ( cursor.moveToFirst() ) {
|
||||||
|
String name = "";
|
||||||
int len_before = m_phoneRecs.size();
|
int len_before = m_phoneRecs.size();
|
||||||
int index = cursor.getColumnIndex(ContactsContract.Contacts._ID );
|
name = cursor.getString( cursor.getColumnIndex( Phone.DISPLAY_NAME));
|
||||||
if ( 0 <= index ) {
|
String number =
|
||||||
String id = cursor.getString( index );
|
cursor.getString( cursor.getColumnIndex( Phone.NUMBER ) );
|
||||||
ContentResolver resolver = getContentResolver();
|
int type = cursor.getInt( cursor.getColumnIndex( Phone.TYPE ) );
|
||||||
Cursor pc =
|
|
||||||
resolver.query( Phone.CONTENT_URI, null,
|
|
||||||
Phone.CONTACT_ID + " = ?",
|
|
||||||
new String[] { id }, null );
|
|
||||||
String name = "";
|
|
||||||
while ( pc.moveToNext() ) {
|
|
||||||
name =
|
|
||||||
pc.getString( pc.getColumnIndex( Phone.DISPLAY_NAME));
|
|
||||||
String number =
|
|
||||||
pc.getString( pc.getColumnIndex( Phone.NUMBER ) );
|
|
||||||
// int type =
|
|
||||||
// pc.getInt( pc.getColumnIndex( Phone.TYPE ) );
|
|
||||||
|
|
||||||
if ( /*Phone.TYPE_MOBILE == type && */0 < number.length() ) {
|
if ( Phone.TYPE_MOBILE == type && 0 < number.length() ) {
|
||||||
m_phoneRecs.add( new PhoneRec( name, number ) );
|
m_phoneRecs.add( new PhoneRec( name, number ) );
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( len_before != m_phoneRecs.size() ) {
|
|
||||||
saveState();
|
|
||||||
rebuildList();
|
|
||||||
} else {
|
|
||||||
int resid = null != name && 0 < name.length()
|
|
||||||
? R.string.sms_nomobilef
|
|
||||||
: R.string.sms_nomobile;
|
|
||||||
String msg = Utils.format( this, resid, name );
|
|
||||||
showOKOnlyDialog( msg );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ( len_before != m_phoneRecs.size() ) {
|
||||||
|
saveState();
|
||||||
|
rebuildList();
|
||||||
|
} else {
|
||||||
|
int resid = null != name && 0 < name.length()
|
||||||
|
? R.string.sms_nomobilef
|
||||||
|
: R.string.sms_nomobile;
|
||||||
|
String msg = Utils.format( this, resid, name );
|
||||||
|
showOKOnlyDialog( msg );
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
} // addPhoneNumbers
|
||||||
|
|
||||||
private void rebuildList()
|
private void rebuildList()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue