From 86907836b2588771f9970168f1bcef1d06b0f0d6 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Fri, 20 Nov 2009 16:50:15 -0800 Subject: [PATCH] Removing the SMS Listener --- framework/src/com/phonegap/PhoneGap.java | 31 +--------- framework/src/com/phonegap/SmsListener.java | 68 --------------------- 2 files changed, 2 insertions(+), 97 deletions(-) delete mode 100644 framework/src/com/phonegap/SmsListener.java diff --git a/framework/src/com/phonegap/PhoneGap.java b/framework/src/com/phonegap/PhoneGap.java index edc1cdd5..0b915d0b 100644 --- a/framework/src/com/phonegap/PhoneGap.java +++ b/framework/src/com/phonegap/PhoneGap.java @@ -46,14 +46,12 @@ public class PhoneGap{ public static String uuid; private Context mCtx; private WebView mAppView; - SmsListener mSmsListener; AudioHandler audio; public PhoneGap(Context ctx, WebView appView) { this.mCtx = ctx; this.mAppView = appView; - - mSmsListener = new SmsListener(ctx,mAppView); + audio = new AudioHandler("/sdcard/tmprecording.mp3", ctx); uuid = getUuid(); } @@ -119,33 +117,8 @@ public class PhoneGap{ return version; } - // Old SMS code, figure out what to do with this! - // BTW: This is awesome! - public void notificationWatchPosition(String filter) - /** - * Starts the listener for incoming notifications of type filter - * TODO: JavaScript Call backs for success and error handling. More filter types. - */ - { - if (filter.contains("SMS")) - { - IntentFilter mFilter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); - mCtx.registerReceiver(mSmsListener,mFilter); - } - } - - public void notificationClearWatch(String filter) - /** - * Stops the listener for incoming notifications of type filter - * TODO: JavaScript Call backs for success and error handling - */ - { - if (filter.contains("SMS")) - { - mCtx.unregisterReceiver(mSmsListener); - } - } + public void httpGet(String url, String file) /** diff --git a/framework/src/com/phonegap/SmsListener.java b/framework/src/com/phonegap/SmsListener.java deleted file mode 100644 index 3a37a982..00000000 --- a/framework/src/com/phonegap/SmsListener.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.phonegap; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.telephony.gsm.SmsMessage; -import android.util.Log; -import android.webkit.WebView; - -public class SmsListener extends BroadcastReceiver -{ - private WebView mAppView; - - public SmsListener(Context ctx, WebView mAppView) - { - this.mAppView = mAppView; - } - - String ACTION = "android.provider.Telephony.SMS_RECEIVED"; - - public void onReceive(Context ctx, Intent intent) - { - SmsMessage[] msg; - if (intent.getAction().equals(ACTION)) - { - msg = getMessagesFromIntent(intent); - String smsContent = null; - String sendersNumber = null; - for(int i=0; i < msg.length; i++) - { - sendersNumber = msg[i].getDisplayOriginatingAddress(); - smsContent = msg[i].getDisplayMessageBody(); - } - onReceiveSMS(sendersNumber, smsContent); - } - } - - protected void onReceiveSMS(String sendersNumber, String smsContent) - /** - * Call back to Java Script - */ - { - mAppView.loadUrl("javascript:onReceiveSms('"+sendersNumber+"',"+"'"+ smsContent +"'"+")"); - } - - private SmsMessage[] getMessagesFromIntent(Intent intent) - { - SmsMessage retMsgs[] = null; - Bundle bdl = intent.getExtras(); - try - { - Object pdus[] = (Object [])bdl.get("pdus"); - retMsgs = new SmsMessage[pdus.length]; - for(int n=0; n < pdus.length; n++) - { - byte[] byteData = (byte[])pdus[n]; - retMsgs[n] = SmsMessage.createFromPdu(byteData); - } - } catch(Exception e) - { - Log.e("SMS_getMessagesFromIntent", "fail", e); - } - return retMsgs; - } - -} -