mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
implement util_phoneNumbersSame in java and call telephony's number
compare method. Skip the java call when the numbers are strcmp-identical.
This commit is contained in:
parent
867e9ffc2f
commit
9ba663ab98
3 changed files with 21 additions and 3 deletions
|
@ -462,9 +462,14 @@ and_util_phoneNumbersSame( XW_UtilCtxt* uc, const XP_UCHAR* p1,
|
|||
{
|
||||
XP_Bool same = 0 == strcmp( p1, p2 );
|
||||
if ( !same ) {
|
||||
/* If they're same, fine, but if not probably need to call into
|
||||
platform code for a closer look */
|
||||
XP_LOGF( "%s(%s,%s)=>%d", __func__, p1, p2, same );
|
||||
UTIL_CBK_HEADER( "phoneNumbersSame",
|
||||
"(Ljava/lang/String;Ljava/lang/String;)Z" );
|
||||
jstring js1 = (*env)->NewStringUTF( env, p1 );
|
||||
jstring js2 = (*env)->NewStringUTF( env, p2 );
|
||||
same = (*env)->CallBooleanMethod( env, util->jutil, mid, js1, js2 );
|
||||
(*env)->DeleteLocalRef( env, js1 );
|
||||
(*env)->DeleteLocalRef( env, js2 );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
return same;
|
||||
}
|
||||
|
|
|
@ -119,4 +119,6 @@ public interface UtilCtxt {
|
|||
boolean warnIllegalWord( String[] words, int turn, boolean turnLost );
|
||||
|
||||
void showChat( String msg );
|
||||
|
||||
boolean phoneNumbersSame( String num1, String num2 );
|
||||
}
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.XWApp;
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
||||
public class UtilCtxtImpl implements UtilCtxt {
|
||||
|
@ -238,6 +241,14 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
subclassOverride( "showChat" );
|
||||
}
|
||||
|
||||
public boolean phoneNumbersSame( String num1, String num2 )
|
||||
{
|
||||
Assert.assertTrue( XWApp.SMSSUPPORTED );
|
||||
boolean same = PhoneNumberUtils.compare( m_context, num1, num2 );
|
||||
DbgUtils.logf( "phoneNumbersSame => %b", same );
|
||||
return same;
|
||||
}
|
||||
|
||||
private void subclassOverride( String name ) {
|
||||
// DbgUtils.logf( "%s::%s() called", getClass().getName(), name );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue