From 0ce0eed585309ee2a9933bd93a58a56f60bf7fc2 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Thu, 16 Jan 2014 13:55:53 -0800 Subject: [PATCH] Didn't test on ICS or lower, getDrawable isn't supported until Jellybean --- src/android/InAppBrowser.java | 37 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 394e62b..4efd99b 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -27,7 +27,6 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.text.InputType; import android.util.Log; @@ -254,16 +253,11 @@ public class InAppBrowser extends CordovaPlugin { scriptToInject = source; } final String finalScriptToInject = scriptToInject; + // This action will have the side-effect of blurring the currently focused element this.cordova.getActivity().runOnUiThread(new Runnable() { - @SuppressLint("NewApi") @Override public void run() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - // This action will have the side-effect of blurring the currently focused element - inAppWebView.loadUrl("javascript:" + finalScriptToInject); - } else { - inAppWebView.evaluateJavascript(finalScriptToInject, null); - } + inAppWebView.loadUrl("javascript:" + finalScriptToInject); } }); } @@ -491,7 +485,14 @@ public class InAppBrowser extends CordovaPlugin { Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); - back.setBackground(backIcon); + if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + back.setBackgroundDrawable(backIcon); + } + else + { + back.setBackground(backIcon); + } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); @@ -508,7 +509,14 @@ public class InAppBrowser extends CordovaPlugin { //forward.setText(">"); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); - forward.setBackground(fwdIcon); + if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + forward.setBackgroundDrawable(fwdIcon); + } + else + { + forward.setBackground(fwdIcon); + } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); @@ -548,7 +556,14 @@ public class InAppBrowser extends CordovaPlugin { //close.setText(buttonLabel); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); - close.setBackground(closeIcon); + if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + close.setBackgroundDrawable(closeIcon); + } + else + { + close.setBackground(closeIcon); + } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog();