Saturday, February 9, 2013

PhoneGap Plugin Updates to TelephoneNumber, IMEI and TTS

I've updated the TelephoneNumber, IMEI and TTS plugins to use the Apache Cordova 2.2.0 API's. That means no more deprecation notices in the Java code and the JavaScript code uses the cordova.require method. However, I'm still slapping the objects into window.plugins so you shouldn't need to change any of your JavaScript code after upgrading.

This completes the upgrade of my plugins that everyone voted on. Next up will be some new work and hopefully I'll be able to get to that WebSpeech shim I've been threatening to do.

18 comments:

Nikita said...

Many thanks for the TTS update. The plugin starts up eventually and works fine; however, for some reason I am never getting the TTS.STARTED message from the StartupWin callback function. I found out that StartupWin is called twice, first with result == 1 (initializing), and the second time with result == null (2 is expected). I am running Cordova 2.3.0.

Simon MacDonald said...

@Nikita

You are not wrong. I'm going to create and issue so I don't forget to come back to this.

Simon MacDonald said...

@Nikita

The issue has been resolved. Go grab the latest TTS.java code.

Unknown said...

Hi ! I have an issue with TelephoneNumberPlugin on Android. I can get tel number on emulator (4.03 & 4.2.2) but not on device (4.0.4) no errors... I you an idea of how resolve it ?

Simon MacDonald said...

@Matthieu Hostache

Do you see anything at all in the "adb logcat"?

Unknown said...

Thanks for answer, but how can i get "adb logcat" ?
I have search a little and the problem seems come of the fact that in much devices there is no information in "settings>About the phone>State>My Phone number". It is a restriction of french providers or it's in all countries ?

Simon MacDonald said...

@Matthieu Hostache

ADB logcat - https://developer.android.com/tools/help/adb.html#logcat

Wow, I've not heard of that restriction. It is not a problem in Canada and the USA.

Unknown said...

@Matthieu Hostache

I have the same problem using TelephoneNumberPlugin in Germany.
My phone doesn't show a number in that submenu entry.

BP said...

Hi,Simon. from debuging info, I found that mTts.speak() was called, but TTS doesn't work ( no sound ), could you help me? thanks. Hanset: HTC OneX(Android 4.1.1)

my index.html as follows:
--------
....
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
tts = cordova.require("cordova/plugin/tts");
window.plugins.tts.startup(startupWin, startupFail);
}

function startupWin(result) {
if (result == TTS.STARTED) {
//console.log("Startup Success = " );
window.plugins.tts.speak("The text to speech service is ready");
}
}

function startupFail(result) {
console.log("Startup failure = " + result);
}


.....
----------

adblogcat as follows:

04-05 23:48:57.631: D/JsMessageQueue(12498): Set native->JS mode to 2
04-05 23:48:57.631: D/DroidGap(12498): DroidGap.init()
04-05 23:48:57.686: D/CordovaWebView(12498): >>> loadUrl(file:///android_asset/www/index.html)
04-05 23:48:57.686: D/PluginManager(12498): init()
04-05 23:48:57.701: D/CordovaWebView(12498): >>> loadUrlNow()
04-05 23:48:57.986: D/DroidGap(12498): Resuming the App
04-05 23:48:58.041: D/DroidGap(12498): Paused the application!
04-05 23:48:58.041: D/CordovaWebView(12498): Handle the pause
04-05 23:48:58.071: D/SoftKeyboardDetect(12498): Ignore this event
04-05 23:48:58.441: D/DroidGap(12498): onMessage(onPageStarted,file:///android_asset/www/index.html)
04-05 23:48:58.451: D/CordovaLog(12498): exception firing pause event from native
04-05 23:48:58.451: D/CordovaLog(12498): null: Line 1 : exception firing pause event from native
04-05 23:48:58.451: I/Web Console(12498): exception firing pause event from native at null:1
04-05 23:48:58.456: D/SoftKeyboardDetect(12498): Ignore this event
04-05 23:48:58.736: D/Cordova(12498): onPageFinished(file:///android_asset/www/index.html)
04-05 23:48:58.736: D/DroidGap(12498): onMessage(onNativeReady,null)
04-05 23:48:58.736: D/DroidGap(12498): onMessage(onPageFinished,file:///android_asset/www/index.html)
04-05 23:48:58.766: E/SQLiteLog(12498): (14) cannot open file at line 30178 of [00bb9c9ce4]
04-05 23:48:58.766: E/SQLiteLog(12498): (14) os_unix.c:30178: (2) open(/CachedGeoposition.db) -
04-05 23:48:58.766: D/WebKit(12498): ERROR:
04-05 23:48:58.766: D/WebKit(12498): SQLite database failed to load from /CachedGeoposition.db
04-05 23:48:58.766: D/WebKit(12498): Cause - unable to open database file
04-05 23:48:58.766: D/WebKit(12498): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
04-05 23:48:58.801: D/DroidGap(12498): onMessage(networkconnection,wifi)
04-05 23:48:58.831: D/DroidGap(12498): onMessage(spinner,stop)
04-05 23:48:58.891: I/TextToSpeech(12498): Sucessfully bound to com.google.android.tts
04-05 23:48:59.341: I/TextToSpeech(12498): Connected to ComponentInfo{com.google.android.tts/com.google.android.tts.GoogleTTSService}
04-05 23:49:00.741: D/DroidGap(12498): onMessage(spinner,stop)

Simon MacDonald said...

@BP

Looks like everything is being setup correctly. Do you have the volume turned up? Second do you know if there is a TTS package installed for your language?

BP said...

Hi, Simon. I know the reason about the TTS issue. Because my locale is Chinese, if I change the locale to English, it work well. Thanks all the same.

Simon MacDonald said...

@BP

Right so you need to install the Mandarin or Cantonese language pack to hear TTS or as you said switch the local to English.

Unknown said...

In the IMEI Android plugin, in imei.js (v2.2.0), the line
return cordova.exec(onSuccess, onFail, 'IMEI', 'get', []);
is broken, maybe? Shouldn't the third parameter be 'ImeiPlugin'?


Cheers
Tommi

Simon MacDonald said...

@Tommi Joutsiniemi

Well as long as you have a plugin line in your res/xml/config.xml like this:

<plugin name="IMEI" value="com.simonmacdonald.imei.IMEIPlugin"/>

it should work.

Sergiy said...

Simon, first of all thanks for creating all this useful stuff!

Could you please help me to resolve the problem with TelephoneNumberPlugin? NetBeans don't compile the project, showing the error: "c:\myproject\nbproject\build.xml:253: Cannot concatenate multiple files into a single file."

Simon MacDonald said...

@Sergiy M.

Well I don't use NetBeans but it looks like there is a problem with your build.xml at line 253.

Sergiy said...

@Simon,

It would be great if you put in readme that plugin requires

I've spent a lot of time figuring that out.

Simon MacDonald said...

@Sergiy M.

Plugin requires what?