diff --git a/bin/templates/project/assets/www/index.html b/bin/templates/project/assets/www/index.html index 8e46f620..22920c81 100644 --- a/bin/templates/project/assets/www/index.html +++ b/bin/templates/project/assets/www/index.html @@ -23,7 +23,7 @@ PhoneGap - + diff --git a/framework/assets/www/index.html b/framework/assets/www/index.html index 3791f9fd..b02bf783 100644 --- a/framework/assets/www/index.html +++ b/framework/assets/www/index.html @@ -19,7 +19,7 @@ - + diff --git a/framework/src/org/apache/cordova/AccelListener.java b/framework/src/org/apache/cordova/AccelListener.java index a7d448e0..fdba7be2 100755 --- a/framework/src/org/apache/cordova/AccelListener.java +++ b/framework/src/org/apache/cordova/AccelListener.java @@ -68,12 +68,12 @@ public class AccelListener extends Plugin implements SensorEventListener { * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * - * @param ctx The context of the main Activity. + * @param cordova The context of the main Activity. */ - public void setContext(CordovaInterface ctx) { - super.setContext(ctx); - this.sensorManager = (SensorManager) ctx.getActivity().getSystemService(Context.SENSOR_SERVICE); + public void setContext(CordovaInterface cordova) { + super.setContext(cordova); + this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); } /** diff --git a/framework/src/org/apache/cordova/App.java b/framework/src/org/apache/cordova/App.java index ed9ec779..7b3dc063 100755 --- a/framework/src/org/apache/cordova/App.java +++ b/framework/src/org/apache/cordova/App.java @@ -49,7 +49,7 @@ public class App extends Plugin { this.clearCache(); } else if (action.equals("show")) { // TODO @bc - Not in master branch. When should this be called? - ctx.getActivity().runOnUiThread(new Runnable() { + cordova.getActivity().runOnUiThread(new Runnable() { public void run() { webView.postMessage("spinner", "stop"); } @@ -162,7 +162,7 @@ public class App extends Plugin { */ @Deprecated public void cancelLoadUrl() { - this.ctx.cancelLoadUrl(); + this.cordova.cancelLoadUrl(); } /** @@ -188,7 +188,7 @@ public class App extends Plugin { */ public void overrideBackbutton(boolean override) { LOG.i("App", "WARNING: Back Button Default Behaviour will be overridden. The backbutton event will be fired!"); - this.ctx.bindBackButton(override); + this.cordova.bindBackButton(override); } /** @@ -200,7 +200,7 @@ public class App extends Plugin { */ public void overrideButton(String button, boolean override) { LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden. The volume event will be fired!"); - ((DroidGap)this.ctx).bindButton(button, override); + this.cordova.bindButton(button, override); } /** * Return whether the Android back button is overridden by the user. @@ -208,7 +208,7 @@ public class App extends Plugin { * @return boolean */ public boolean isBackbuttonOverridden() { - return this.ctx.isBackButtonBound(); + return this.cordova.isBackButtonBound(); } /** diff --git a/framework/src/org/apache/cordova/AudioHandler.java b/framework/src/org/apache/cordova/AudioHandler.java index a866d4f4..492043bf 100755 --- a/framework/src/org/apache/cordova/AudioHandler.java +++ b/framework/src/org/apache/cordova/AudioHandler.java @@ -305,7 +305,7 @@ public class AudioHandler extends Plugin { */ @SuppressWarnings("deprecation") public void setAudioOutputDevice(int output) { - AudioManager audiMgr = (AudioManager) this.ctx.getActivity().getSystemService(Context.AUDIO_SERVICE); + AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE); if (output == 2) { audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL); } @@ -324,7 +324,7 @@ public class AudioHandler extends Plugin { */ @SuppressWarnings("deprecation") public int getAudioOutputDevice() { - AudioManager audiMgr = (AudioManager) this.ctx.getActivity().getSystemService(Context.AUDIO_SERVICE); + AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE); if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) { return 1; } diff --git a/framework/src/org/apache/cordova/AudioPlayer.java b/framework/src/org/apache/cordova/AudioPlayer.java index e975afaf..5df00f9c 100755 --- a/framework/src/org/apache/cordova/AudioPlayer.java +++ b/framework/src/org/apache/cordova/AudioPlayer.java @@ -88,7 +88,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3"; } else { - this.tempFile = "/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/tmprecording.mp3"; + this.tempFile = "/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/tmprecording.mp3"; } } @@ -160,7 +160,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + file)); } else { - f.renameTo(new File("/data/data/" + handler.ctx.getActivity().getPackageName() + "/cache/" + file)); + f.renameTo(new File("/data/data/" + handler.cordova.getActivity().getPackageName() + "/cache/" + file)); } } @@ -220,7 +220,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On else { if (file.startsWith("/android_asset/")) { String f = file.substring(15); - android.content.res.AssetFileDescriptor fd = this.handler.ctx.getActivity().getAssets().openFd(f); + android.content.res.AssetFileDescriptor fd = this.handler.cordova.getActivity().getAssets().openFd(f); this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength()); } else { diff --git a/framework/src/org/apache/cordova/BatteryListener.java b/framework/src/org/apache/cordova/BatteryListener.java index bca96332..eb0ea98a 100755 --- a/framework/src/org/apache/cordova/BatteryListener.java +++ b/framework/src/org/apache/cordova/BatteryListener.java @@ -73,7 +73,7 @@ public class BatteryListener extends Plugin { updateBatteryInfo(intent); } }; - ctx.getActivity().registerReceiver(this.receiver, intentFilter); + cordova.getActivity().registerReceiver(this.receiver, intentFilter); } // Don't return any result now, since status results will be sent when events come in from broadcast receiver @@ -105,7 +105,7 @@ public class BatteryListener extends Plugin { private void removeBatteryListener() { if (this.receiver != null) { try { - this.ctx.getActivity().unregisterReceiver(this.receiver); + this.cordova.getActivity().unregisterReceiver(this.receiver); this.receiver = null; } catch (Exception e) { Log.e(LOG_TAG, "Error unregistering battery receiver: " + e.getMessage(), e); diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java index 436c232f..1afaf8db 100755 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@ -176,8 +176,8 @@ public class CameraLauncher extends Plugin { intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); - if (this.ctx != null) { - this.ctx.startActivityForResult((Plugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); + if (this.cordova != null) { + this.cordova.startActivityForResult((Plugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); } // else // LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); @@ -192,9 +192,9 @@ public class CameraLauncher extends Plugin { private File createCaptureFile(int encodingType) { File photo = null; if (encodingType == JPEG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()), "Pic.jpg"); + photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Pic.jpg"); } else if (encodingType == PNG) { - photo = new File(DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()), "Pic.png"); + photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Pic.png"); } else { throw new IllegalArgumentException("Invalid Encoding Type: " + encodingType); } @@ -228,8 +228,8 @@ public class CameraLauncher extends Plugin { intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); - if (this.ctx != null) { - this.ctx.startActivityForResult((Plugin) this, Intent.createChooser(intent, + if (this.cordova != null) { + this.cordova.startActivityForResult((Plugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } } @@ -299,7 +299,7 @@ public class CameraLauncher extends Plugin { ExifHelper exif = new ExifHelper(); try { if (this.encodingType == JPEG) { - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()) + "/Pic.jpg"); + exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/Pic.jpg"); exif.readExifData(); } } catch (IOException e) { @@ -313,10 +313,10 @@ public class CameraLauncher extends Plugin { // Read in bitmap of captured image Bitmap bitmap; try { - bitmap = android.provider.MediaStore.Images.Media.getBitmap(this.ctx.getActivity().getContentResolver(), imageUri); + bitmap = android.provider.MediaStore.Images.Media.getBitmap(this.cordova.getActivity().getContentResolver(), imageUri); } catch (FileNotFoundException e) { Uri uri = intent.getData(); - android.content.ContentResolver resolver = this.ctx.getActivity().getContentResolver(); + android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver(); bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); } @@ -336,11 +336,11 @@ public class CameraLauncher extends Plugin { values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); Uri uri = null; try { - uri = this.ctx.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { LOG.d(LOG_TAG, "Can't write to external media storage."); try { - uri = this.ctx.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException ex) { LOG.d(LOG_TAG, "Can't write to internal media storage."); this.failPicture("Error capturing image - no media storage found."); @@ -349,13 +349,13 @@ public class CameraLauncher extends Plugin { } // Add compressed version of captured image to returned media store Uri - OutputStream os = this.ctx.getActivity().getContentResolver().openOutputStream(uri); + OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); os.close(); // Restore exif data to file if (this.encodingType == JPEG) { - exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.ctx)); + exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); } @@ -388,7 +388,7 @@ public class CameraLauncher extends Plugin { else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { if (resultCode == Activity.RESULT_OK) { Uri uri = intent.getData(); - android.content.ContentResolver resolver = this.ctx.getActivity().getContentResolver(); + android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver(); // If you ask for video or all media type you will automatically get back a file URI // and there will be no attempt to resize any returned data @@ -401,7 +401,7 @@ public class CameraLauncher extends Plugin { try { Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); String[] cols = { MediaStore.Images.Media.ORIENTATION }; - Cursor cursor = this.ctx.getActivity().getContentResolver().query(intent.getData(), + Cursor cursor = this.cordova.getActivity().getContentResolver().query(intent.getData(), cols, null, null, null); if (cursor != null) { @@ -433,14 +433,14 @@ public class CameraLauncher extends Plugin { Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); bitmap = scaleBitmap(bitmap); - String fileName = DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()) + "/resize.jpg"; + String fileName = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg"; OutputStream os = new FileOutputStream(fileName); bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os); os.close(); // Restore exif data to file if (this.encodingType == JPEG) { - exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.ctx)); + exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); } @@ -477,7 +477,7 @@ public class CameraLauncher extends Plugin { * @return a cursor */ private Cursor queryImgDB() { - return this.ctx.getActivity().getContentResolver().query( + return this.cordova.getActivity().getContentResolver().query( android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.Images.Media._ID }, null, @@ -506,7 +506,7 @@ public class CameraLauncher extends Plugin { cursor.moveToLast(); int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID))) - 1; Uri uri = Uri.parse(MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "/" + id); - this.ctx.getActivity().getContentResolver().delete(uri, null, null); + this.cordova.getActivity().getContentResolver().delete(uri, null, null); } } diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java index 6e87f1e7..a2dfafdc 100644 --- a/framework/src/org/apache/cordova/Capture.java +++ b/framework/src/org/apache/cordova/Capture.java @@ -195,7 +195,7 @@ public class Capture extends Plugin { private void captureAudio() { Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION); - this.ctx.startActivityForResult((Plugin) this, intent, CAPTURE_AUDIO); + this.cordova.startActivityForResult((Plugin) this, intent, CAPTURE_AUDIO); } /** @@ -205,11 +205,11 @@ public class Capture extends Plugin { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); // Specify file so that large image is captured and returned - File photo = new File(DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()), "Capture.jpg"); + File photo = new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), "Capture.jpg"); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); - this.ctx.startActivityForResult((Plugin) this, intent, CAPTURE_IMAGE); + this.cordova.startActivityForResult((Plugin) this, intent, CAPTURE_IMAGE); } /** @@ -220,7 +220,7 @@ public class Capture extends Plugin { // Introduced in API 8 //intent.putExtra(android.provider.MediaStore.EXTRA_DURATION_LIMIT, duration); - this.ctx.startActivityForResult((Plugin) this, intent, CAPTURE_VIDEO); + this.cordova.startActivityForResult((Plugin) this, intent, CAPTURE_VIDEO); } /** @@ -258,11 +258,11 @@ public class Capture extends Plugin { try { // Create an ExifHelper to save the exif data that is lost during compression ExifHelper exif = new ExifHelper(); - exif.createInFile(DirectoryManager.getTempDirectoryPath(this.ctx.getActivity()) + "/Capture.jpg"); + exif.createInFile(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/Capture.jpg"); exif.readExifData(); // Read in bitmap of captured image - Bitmap bitmap = android.provider.MediaStore.Images.Media.getBitmap(this.ctx.getActivity().getContentResolver(), imageUri); + Bitmap bitmap = android.provider.MediaStore.Images.Media.getBitmap(this.cordova.getActivity().getContentResolver(), imageUri); // Create entry in media store for image // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it) @@ -270,11 +270,11 @@ public class Capture extends Plugin { values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG); Uri uri = null; try { - uri = this.ctx.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException e) { LOG.d(LOG_TAG, "Can't write to external media storage."); try { - uri = this.ctx.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); + uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException ex) { LOG.d(LOG_TAG, "Can't write to internal media storage."); this.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found.")); @@ -283,7 +283,7 @@ public class Capture extends Plugin { } // Add compressed version of captured image to returned media store Uri - OutputStream os = this.ctx.getActivity().getContentResolver().openOutputStream(uri); + OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); os.close(); @@ -292,7 +292,7 @@ public class Capture extends Plugin { System.gc(); // Restore exif data to file - exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.ctx)); + exif.createOutFile(FileUtils.getRealPathFromURI(uri, this.cordova)); exif.writeExifData(); // Add image to results @@ -356,7 +356,7 @@ public class Capture extends Plugin { * @throws IOException */ private JSONObject createMediaFile(Uri data) { - File fp = new File(FileUtils.getRealPathFromURI(data, this.ctx)); + File fp = new File(FileUtils.getRealPathFromURI(data, this.cordova)); JSONObject obj = new JSONObject(); try { diff --git a/framework/src/org/apache/cordova/CompassListener.java b/framework/src/org/apache/cordova/CompassListener.java index d6e54a7e..83fcdd0a 100755 --- a/framework/src/org/apache/cordova/CompassListener.java +++ b/framework/src/org/apache/cordova/CompassListener.java @@ -67,11 +67,11 @@ public class CompassListener extends Plugin implements SensorEventListener { * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * - * @param ctx The context of the main Activity. + * @param cordova The context of the main Activity. */ - public void setContext(CordovaInterface ctx) { - super.setContext(ctx); - this.sensorManager = (SensorManager) ctx.getActivity().getSystemService(Context.SENSOR_SERVICE); + public void setContext(CordovaInterface cordova) { + super.setContext(cordova); + this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); } /** diff --git a/framework/src/org/apache/cordova/ContactManager.java b/framework/src/org/apache/cordova/ContactManager.java index b07fba0a..31b5452f 100755 --- a/framework/src/org/apache/cordova/ContactManager.java +++ b/framework/src/org/apache/cordova/ContactManager.java @@ -69,7 +69,7 @@ public class ContactManager extends Plugin { * older phones. */ if (this.contactAccessor == null) { - this.contactAccessor = new ContactAccessorSdk5(this.webView, this.ctx); + this.contactAccessor = new ContactAccessorSdk5(this.webView, this.cordova); } try { diff --git a/framework/src/org/apache/cordova/CordovaChromeClient.java b/framework/src/org/apache/cordova/CordovaChromeClient.java index a23aac4e..86b575b8 100755 --- a/framework/src/org/apache/cordova/CordovaChromeClient.java +++ b/framework/src/org/apache/cordova/CordovaChromeClient.java @@ -45,16 +45,16 @@ public class CordovaChromeClient extends WebChromeClient { private String TAG = "CordovaLog"; private long MAX_QUOTA = 100 * 1024 * 1024; - private CordovaInterface ctx; + private CordovaInterface cordova; private CordovaWebView appView; /** * Constructor. * - * @param ctx + * @param cordova */ - public CordovaChromeClient(CordovaInterface ctx) { - this.ctx = ctx; + public CordovaChromeClient(CordovaInterface cordova) { + this.cordova = cordova; } /** @@ -64,7 +64,7 @@ public class CordovaChromeClient extends WebChromeClient { * @param app */ public CordovaChromeClient(CordovaInterface ctx, CordovaWebView app) { - this.ctx = ctx; + this.cordova = ctx; this.appView = app; } @@ -87,7 +87,7 @@ public class CordovaChromeClient extends WebChromeClient { */ @Override public boolean onJsAlert(WebView view, String url, String message, final JsResult result) { - AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx.getActivity()); + AlertDialog.Builder dlg = new AlertDialog.Builder(this.cordova.getActivity()); dlg.setMessage(message); dlg.setTitle("Alert"); //Don't let alerts break the back button @@ -131,7 +131,7 @@ public class CordovaChromeClient extends WebChromeClient { */ @Override public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { - AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx.getActivity()); + AlertDialog.Builder dlg = new AlertDialog.Builder(this.cordova.getActivity()); dlg.setMessage(message); dlg.setTitle("Confirm"); dlg.setCancelable(true); @@ -243,9 +243,9 @@ public class CordovaChromeClient extends WebChromeClient { // Show dialog else { final JsPromptResult res = result; - AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx.getActivity()); + AlertDialog.Builder dlg = new AlertDialog.Builder(this.cordova.getActivity()); dlg.setMessage(message); - final EditText input = new EditText(this.ctx.getActivity()); + final EditText input = new EditText(this.cordova.getActivity()); if (defaultValue != null) { input.setText(defaultValue); } diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 308d222f..3337be23 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -55,7 +55,7 @@ public class CordovaWebView extends WebView { public CallbackServer callbackServer; /** Actvities and other important classes **/ - private CordovaInterface mCtx; + private CordovaInterface cordova; CordovaWebViewClient viewClient; @SuppressWarnings("unused") private CordovaChromeClient chromeClient; @@ -79,7 +79,7 @@ public class CordovaWebView extends WebView { super(context); if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.cordova = (CordovaInterface) context; } else { @@ -99,14 +99,14 @@ public class CordovaWebView extends WebView { super(context, attrs); if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.cordova = (CordovaInterface) context; } else { Log.d(TAG, "Your activity must implement CordovaInterface to work"); } - this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this)); - this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this)); + this.setWebChromeClient(new CordovaChromeClient(this.cordova, this)); + this.setWebViewClient(new CordovaWebViewClient(this.cordova, this)); this.loadConfiguration(); this.setup(); } @@ -123,14 +123,14 @@ public class CordovaWebView extends WebView { super(context, attrs, defStyle); if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.cordova = (CordovaInterface) context; } else { Log.d(TAG, "Your activity must implement CordovaInterface to work"); } - this.setWebChromeClient(new CordovaChromeClient(this.mCtx, this)); - this.setWebViewClient(new CordovaWebViewClient(this.mCtx, this)); + this.setWebChromeClient(new CordovaChromeClient(this.cordova, this)); + this.setWebViewClient(new CordovaWebViewClient(this.cordova, this)); this.loadConfiguration(); this.setup(); } @@ -147,14 +147,14 @@ public class CordovaWebView extends WebView { super(context, attrs, defStyle, privateBrowsing); if (CordovaInterface.class.isInstance(context)) { - this.mCtx = (CordovaInterface) context; + this.cordova = (CordovaInterface) context; } else { Log.d(TAG, "Your activity must implement CordovaInterface to work"); } - this.setWebChromeClient(new CordovaChromeClient(this.mCtx)); - this.setWebViewClient(new CordovaWebViewClient(this.mCtx)); + this.setWebChromeClient(new CordovaChromeClient(this.cordova)); + this.setWebViewClient(new CordovaWebViewClient(this.cordova)); this.loadConfiguration(); this.setup(); } @@ -180,7 +180,7 @@ public class CordovaWebView extends WebView { // Enable database settings.setDatabaseEnabled(true); - String databasePath = this.mCtx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); + String databasePath = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabasePath(databasePath); // Enable DOM storage @@ -191,7 +191,7 @@ public class CordovaWebView extends WebView { //Start up the plugin manager try { - this.pluginManager = new PluginManager(this, this.mCtx); + this.pluginManager = new PluginManager(this, this.cordova); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -383,13 +383,13 @@ public class CordovaWebView extends WebView { // If timeout, then stop loading and handle error if (me.loadUrlTimeout == currentLoadUrlTimeout) { - me.mCtx.getActivity().runOnUiThread(loadError); + me.cordova.getActivity().runOnUiThread(loadError); } } }; // Load url - this.mCtx.getActivity().runOnUiThread(new Runnable() { + this.cordova.getActivity().runOnUiThread(new Runnable() { public void run() { Thread thread = new Thread(timeoutCheck); thread.start(); @@ -558,7 +558,7 @@ public class CordovaWebView extends WebView { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); - mCtx.getActivity().startActivity(intent); + cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } @@ -570,7 +570,7 @@ public class CordovaWebView extends WebView { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); - mCtx.getActivity().startActivity(intent); + cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } @@ -585,7 +585,7 @@ public class CordovaWebView extends WebView { * */ private void loadConfiguration() { - int id = getResources().getIdentifier("cordova", "xml", this.mCtx.getActivity().getPackageName()); + int id = getResources().getIdentifier("cordova", "xml", this.cordova.getActivity().getPackageName()); if (id == 0) { LOG.i("CordovaLog", "cordova.xml missing. Ignoring..."); return; @@ -616,7 +616,7 @@ public class CordovaWebView extends WebView { LOG.i("CordovaLog", "Found preference for %s=%s", name, value); // Save preferences in Intent - this.mCtx.getActivity().getIntent().putExtra(name, value); + this.cordova.getActivity().getIntent().putExtra(name, value); } } try { @@ -637,8 +637,8 @@ public class CordovaWebView extends WebView { } if ("true".equals(this.getProperty("fullscreen", "false"))) { - this.mCtx.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - this.mCtx.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + this.cordova.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } } @@ -650,7 +650,7 @@ public class CordovaWebView extends WebView { * @return */ public String getProperty(String name, String defaultValue) { - Bundle bundle = this.mCtx.getActivity().getIntent().getExtras(); + Bundle bundle = this.cordova.getActivity().getIntent().getExtras(); if (bundle == null) { return defaultValue; } diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index 3cda1b11..c9a32611 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -44,7 +44,7 @@ import android.webkit.WebViewClient; public class CordovaWebViewClient extends WebViewClient { private static final String TAG = "Cordova"; - CordovaInterface ctx; + CordovaInterface cordova; CordovaWebView appView; private boolean doClearHistory = false; @@ -54,20 +54,20 @@ public class CordovaWebViewClient extends WebViewClient { /** * Constructor. * - * @param ctx + * @param cordova */ - public CordovaWebViewClient(CordovaInterface ctx) { - this.ctx = ctx; + public CordovaWebViewClient(CordovaInterface cordova) { + this.cordova = cordova; } /** * Constructor. * - * @param ctx + * @param cordova * @param view */ - public CordovaWebViewClient(CordovaInterface ctx, CordovaWebView view) { - this.ctx = ctx; + public CordovaWebViewClient(CordovaInterface cordova, CordovaWebView view) { + this.cordova = cordova; this.appView = view; } @@ -100,7 +100,7 @@ public class CordovaWebViewClient extends WebViewClient { try { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); - this.ctx.getActivity().startActivity(intent); + this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error dialing " + url + ": " + e.toString()); } @@ -111,7 +111,7 @@ public class CordovaWebViewClient extends WebViewClient { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); - this.ctx.getActivity().startActivity(intent); + this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error showing map " + url + ": " + e.toString()); } @@ -122,7 +122,7 @@ public class CordovaWebViewClient extends WebViewClient { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); - this.ctx.getActivity().startActivity(intent); + this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error sending email " + url + ": " + e.toString()); } @@ -154,7 +154,7 @@ public class CordovaWebViewClient extends WebViewClient { intent.setData(Uri.parse("sms:" + address)); intent.putExtra("address", address); intent.setType("vnd.android-dir/mms-sms"); - this.ctx.getActivity().startActivity(intent); + this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error sending sms " + url + ":" + e.toString()); } @@ -178,7 +178,7 @@ public class CordovaWebViewClient extends WebViewClient { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); - this.ctx.getActivity().startActivity(intent); + this.cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } @@ -280,7 +280,7 @@ public class CordovaWebViewClient extends WebViewClient { public void run() { try { Thread.sleep(2000); - ctx.getActivity().runOnUiThread(new Runnable() { + cordova.getActivity().runOnUiThread(new Runnable() { public void run() { appView.postMessage("spinner", "stop"); } @@ -342,8 +342,8 @@ public class CordovaWebViewClient extends WebViewClient { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { - final String packageName = this.ctx.getActivity().getPackageName(); - final PackageManager pm = this.ctx.getActivity().getPackageManager(); + final String packageName = this.cordova.getActivity().getPackageName(); + final PackageManager pm = this.cordova.getActivity().getPackageManager(); ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); diff --git a/framework/src/org/apache/cordova/Device.java b/framework/src/org/apache/cordova/Device.java index 6fd151ea..2d77f54d 100644 --- a/framework/src/org/apache/cordova/Device.java +++ b/framework/src/org/apache/cordova/Device.java @@ -38,7 +38,7 @@ import android.telephony.TelephonyManager; public class Device extends Plugin { public static final String TAG = "Device"; - public static String cordovaVersion = "1.8.0"; // Cordova version + public static String cordovaVersion = "1.9.0rc1"; // Cordova version public static String platform = "Android"; // Device OS public static String uuid; // Device UUID @@ -54,10 +54,10 @@ public class Device extends Plugin { * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * - * @param ctx The context of the main Activity. + * @param cordova The context of the main Activity. */ - public void setContext(CordovaInterface ctx) { - super.setContext(ctx); + public void setContext(CordovaInterface cordova) { + super.setContext(cordova); Device.uuid = getUuid(); this.initTelephonyReceiver(); } @@ -110,7 +110,7 @@ public class Device extends Plugin { * Unregister receiver. */ public void onDestroy() { - this.ctx.getActivity().unregisterReceiver(this.telephonyReceiver); + this.cordova.getActivity().unregisterReceiver(this.telephonyReceiver); } //-------------------------------------------------------------------------- @@ -125,7 +125,7 @@ public class Device extends Plugin { private void initTelephonyReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); - //final CordovaInterface myctx = this.ctx; + //final CordovaInterface mycordova = this.cordova; this.telephonyReceiver = new BroadcastReceiver() { @Override @@ -153,7 +153,7 @@ public class Device extends Plugin { }; // Register the receiver - this.ctx.getActivity().registerReceiver(this.telephonyReceiver, intentFilter); + this.cordova.getActivity().registerReceiver(this.telephonyReceiver, intentFilter); } /** @@ -171,7 +171,7 @@ public class Device extends Plugin { * @return */ public String getUuid() { - String uuid = Settings.Secure.getString(this.ctx.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); + String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); return uuid; } diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java index 4accd55c..824ad020 100644 --- a/framework/src/org/apache/cordova/FileTransfer.java +++ b/framework/src/org/apache/cordova/FileTransfer.java @@ -524,7 +524,7 @@ public class FileTransfer extends Plugin { private InputStream getPathFromUri(String path) throws FileNotFoundException { if (path.startsWith("content:")) { Uri uri = Uri.parse(path); - return ctx.getActivity().getContentResolver().openInputStream(uri); + return cordova.getActivity().getContentResolver().openInputStream(uri); } else if (path.startsWith("file://")) { int question = path.indexOf("?"); diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index 825fabe2..1dc6e052 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -223,9 +223,9 @@ public class FileUtils extends Plugin { */ private void notifyDelete(String filePath) { String newFilePath = stripFileProtocol(filePath); - int result = this.ctx.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + int result = this.cordova.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.DATA + " = ?", - new String[] { filePath }); + new String[] { newFilePath }); } /** @@ -246,7 +246,7 @@ public class FileUtils extends Plugin { // Handle the special case where you get an Android content:// uri. if (decoded.startsWith("content:")) { - Cursor cursor = this.ctx.getActivity().managedQuery(Uri.parse(decoded), new String[] { MediaStore.Images.Media.DATA }, null, null, null); + Cursor cursor = this.cordova.getActivity().managedQuery(Uri.parse(decoded), new String[] { MediaStore.Images.Media.DATA }, null, null, null); // Note: MediaStore.Images/Audio/Video.Media.DATA is always "_data" int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); @@ -728,9 +728,9 @@ public class FileUtils extends Plugin { private boolean atRootDirectory(String filePath) { filePath = stripFileProtocol(filePath); - if (filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + ctx.getActivity().getPackageName() + "/cache") || + if (filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache") || filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath()) || - filePath.equals("/data/data/" + ctx.getActivity().getPackageName())) { + filePath.equals("/data/data/" + cordova.getActivity().getPackageName())) { return true; } return false; @@ -819,16 +819,16 @@ public class FileUtils extends Plugin { fs.put("name", "temporary"); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { fp = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + - "/Android/data/" + ctx.getActivity().getPackageName() + "/cache/"); + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache/"); // Create the cache dir if it doesn't exist. fp.mkdirs(); fs.put("root", getEntry(Environment.getExternalStorageDirectory().getAbsolutePath() + - "/Android/data/" + ctx.getActivity().getPackageName() + "/cache/")); + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache/")); } else { - fp = new File("/data/data/" + ctx.getActivity().getPackageName() + "/cache/"); + fp = new File("/data/data/" + cordova.getActivity().getPackageName() + "/cache/"); // Create the cache dir if it doesn't exist. fp.mkdirs(); - fs.put("root", getEntry("/data/data/" + ctx.getActivity().getPackageName() + "/cache/")); + fs.put("root", getEntry("/data/data/" + cordova.getActivity().getPackageName() + "/cache/")); } } else if (type == PERSISTENT) { @@ -836,7 +836,7 @@ public class FileUtils extends Plugin { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { fs.put("root", getEntry(Environment.getExternalStorageDirectory())); } else { - fs.put("root", getEntry("/data/data/" + ctx.getActivity().getPackageName())); + fs.put("root", getEntry("/data/data/" + cordova.getActivity().getPackageName())); } } else { @@ -943,7 +943,7 @@ public class FileUtils extends Plugin { String contentType = null; if (filename.startsWith("content:")) { Uri fileUri = Uri.parse(filename); - contentType = this.ctx.getActivity().getContentResolver().getType(fileUri); + contentType = this.cordova.getActivity().getContentResolver().getType(fileUri); } else { contentType = getMimeType(filename); @@ -1026,7 +1026,7 @@ public class FileUtils extends Plugin { private InputStream getPathFromUri(String path) throws FileNotFoundException { if (path.startsWith("content")) { Uri uri = Uri.parse(path); - return ctx.getActivity().getContentResolver().openInputStream(uri); + return cordova.getActivity().getContentResolver().openInputStream(uri); } else { path = stripFileProtocol(path); @@ -1038,13 +1038,13 @@ public class FileUtils extends Plugin { * Queries the media store to find out what the file path is for the Uri we supply * * @param contentUri the Uri of the audio/image/video - * @param ctx) the current applicaiton context + * @param cordova) the current applicaiton context * @return the full path to the file */ @SuppressWarnings("deprecation") - protected static String getRealPathFromURI(Uri contentUri, CordovaInterface ctx) { + protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) { String[] proj = { _DATA }; - Cursor cursor = ctx.getActivity().managedQuery(contentUri, proj, null, null, null); + Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(_DATA); cursor.moveToFirst(); return cursor.getString(column_index); diff --git a/framework/src/org/apache/cordova/GeoBroker.java b/framework/src/org/apache/cordova/GeoBroker.java index e53358e3..499d4468 100755 --- a/framework/src/org/apache/cordova/GeoBroker.java +++ b/framework/src/org/apache/cordova/GeoBroker.java @@ -55,7 +55,7 @@ public class GeoBroker extends Plugin { */ public PluginResult execute(String action, JSONArray args, String callbackId) { if (this.locationManager == null) { - this.locationManager = (LocationManager) this.ctx.getActivity().getSystemService(Context.LOCATION_SERVICE); + this.locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE); this.networkListener = new NetworkListener(this.locationManager, this); this.gpsListener = new GPSListener(this.locationManager, this); } diff --git a/framework/src/org/apache/cordova/NetworkManager.java b/framework/src/org/apache/cordova/NetworkManager.java index 4661ddb6..37f0933e 100755 --- a/framework/src/org/apache/cordova/NetworkManager.java +++ b/framework/src/org/apache/cordova/NetworkManager.java @@ -84,11 +84,11 @@ public class NetworkManager extends Plugin { * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * - * @param ctx The context of the main Activity. + * @param cordova The context of the main Activity. */ - public void setContext(CordovaInterface ctx) { - super.setContext(ctx); - this.sockMan = (ConnectivityManager) ctx.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); + public void setContext(CordovaInterface cordova) { + super.setContext(cordova); + this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); this.connectionCallbackId = null; // We need to listen to connectivity events to update navigator.connection @@ -102,7 +102,7 @@ public class NetworkManager extends Plugin { updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO)); } }; - ctx.getActivity().registerReceiver(this.receiver, intentFilter); + cordova.getActivity().registerReceiver(this.receiver, intentFilter); } } @@ -146,7 +146,7 @@ public class NetworkManager extends Plugin { public void onDestroy() { if (this.receiver != null) { try { - this.ctx.getActivity().unregisterReceiver(this.receiver); + this.cordova.getActivity().unregisterReceiver(this.receiver); } catch (Exception e) { Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e); } diff --git a/framework/src/org/apache/cordova/Notification.java b/framework/src/org/apache/cordova/Notification.java index ed0b4365..7a866a8d 100755 --- a/framework/src/org/apache/cordova/Notification.java +++ b/framework/src/org/apache/cordova/Notification.java @@ -143,7 +143,7 @@ public class Notification extends Plugin { */ public void beep(long count) { Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); - Ringtone notification = RingtoneManager.getRingtone(this.ctx.getActivity().getBaseContext(), ringtone); + Ringtone notification = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), ringtone); // If phone is not set to silent mode if (notification != null) { @@ -171,7 +171,7 @@ public class Notification extends Plugin { if (time == 0) { time = 500; } - Vibrator vibrator = (Vibrator) this.ctx.getActivity().getSystemService(Context.VIBRATOR_SERVICE); + Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(time); } @@ -184,13 +184,13 @@ public class Notification extends Plugin { */ public synchronized void alert(final String message, final String title, final String buttonLabel, final String callbackId) { - final CordovaInterface ctx = this.ctx; + final CordovaInterface cordova = this.cordova; final Notification notification = this; Runnable runnable = new Runnable() { public void run() { - AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getActivity()); + AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); @@ -205,7 +205,7 @@ public class Notification extends Plugin { dlg.show(); }; }; - this.ctx.getActivity().runOnUiThread(runnable); + this.cordova.getActivity().runOnUiThread(runnable); } /** @@ -220,13 +220,13 @@ public class Notification extends Plugin { */ public synchronized void confirm(final String message, final String title, String buttonLabels, final String callbackId) { - final CordovaInterface ctx = this.ctx; + final CordovaInterface cordova = this.cordova; final Notification notification = this; final String[] fButtons = buttonLabels.split(","); Runnable runnable = new Runnable() { public void run() { - AlertDialog.Builder dlg = new AlertDialog.Builder(ctx.getActivity()); + AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); @@ -269,7 +269,7 @@ public class Notification extends Plugin { dlg.show(); }; }; - this.ctx.getActivity().runOnUiThread(runnable); + this.cordova.getActivity().runOnUiThread(runnable); } /** @@ -284,10 +284,10 @@ public class Notification extends Plugin { this.spinnerDialog = null; } final Notification notification = this; - final CordovaInterface ctx = this.ctx; + final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { - notification.spinnerDialog = ProgressDialog.show(ctx.getActivity(), title, message, true, true, + notification.spinnerDialog = ProgressDialog.show(cordova.getActivity(), title, message, true, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { notification.spinnerDialog = null; @@ -295,7 +295,7 @@ public class Notification extends Plugin { }); } }; - this.ctx.getActivity().runOnUiThread(runnable); + this.cordova.getActivity().runOnUiThread(runnable); } /** @@ -320,10 +320,10 @@ public class Notification extends Plugin { this.progressDialog = null; } final Notification notification = this; - final CordovaInterface ctx = this.ctx; + final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { - notification.progressDialog = new ProgressDialog(ctx.getActivity()); + notification.progressDialog = new ProgressDialog(cordova.getActivity()); notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); notification.progressDialog.setTitle(title); notification.progressDialog.setMessage(message); @@ -339,7 +339,7 @@ public class Notification extends Plugin { notification.progressDialog.show(); } }; - this.ctx.getActivity().runOnUiThread(runnable); + this.cordova.getActivity().runOnUiThread(runnable); } /** diff --git a/framework/src/org/apache/cordova/Storage.java b/framework/src/org/apache/cordova/Storage.java index ef87b45a..13fd919c 100755 --- a/framework/src/org/apache/cordova/Storage.java +++ b/framework/src/org/apache/cordova/Storage.java @@ -141,7 +141,7 @@ public class Storage extends Plugin { // If no database path, generate from application package if (this.path == null) { - this.path = this.ctx.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); + this.path = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); } this.dbName = this.path + File.pathSeparator + db + ".db"; diff --git a/framework/src/org/apache/cordova/TempListener.java b/framework/src/org/apache/cordova/TempListener.java index 21c0de01..c65bc879 100755 --- a/framework/src/org/apache/cordova/TempListener.java +++ b/framework/src/org/apache/cordova/TempListener.java @@ -46,11 +46,11 @@ public class TempListener extends Plugin implements SensorEventListener { * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * - * @param ctx The context of the main Activity. + * @param cordova The context of the main Activity. */ - public void setContext(CordovaInterface ctx) { - super.setContext(ctx); - this.sensorManager = (SensorManager) ctx.getActivity().getSystemService(Context.SENSOR_SERVICE); + public void setContext(CordovaInterface cordova) { + super.setContext(cordova); + this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE); } /** diff --git a/framework/src/org/apache/cordova/api/CordovaInterface.java b/framework/src/org/apache/cordova/api/CordovaInterface.java index 46b692b9..64a2743e 100755 --- a/framework/src/org/apache/cordova/api/CordovaInterface.java +++ b/framework/src/org/apache/cordova/api/CordovaInterface.java @@ -76,4 +76,6 @@ public interface CordovaInterface { * @return Object or null */ public Object onMessage(String id, Object data); + + public abstract void bindButton(String button, boolean override); } diff --git a/framework/src/org/apache/cordova/api/Plugin.java b/framework/src/org/apache/cordova/api/Plugin.java index 143655b1..1ac42f02 100755 --- a/framework/src/org/apache/cordova/api/Plugin.java +++ b/framework/src/org/apache/cordova/api/Plugin.java @@ -33,6 +33,7 @@ public abstract class Plugin implements IPlugin { public String id; public CordovaWebView webView; // WebView object public CordovaInterface ctx; // CordovaActivity object + public CordovaInterface cordova; /** * Executes the request and returns PluginResult. @@ -61,7 +62,8 @@ public abstract class Plugin implements IPlugin { * @param ctx The context of the main Activity. */ public void setContext(CordovaInterface ctx) { - this.ctx = ctx; + this.cordova = ctx; + this.ctx = cordova; } /**