amazon-fireos related changes.
This commit is contained in:
parent
79f73fbe62
commit
69ca780772
17
plugin.xml
17
plugin.xml
@ -78,7 +78,24 @@
|
|||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<source-file src="src/amazon/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
<source-file src="src/amazon/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||||
|
<source-file src="src/android/InAppBrowserDialog.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||||
<source-file src="src/amazon/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
<source-file src="src/amazon/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||||
|
|
||||||
|
<!-- drawable src/android/resources -->
|
||||||
|
<resource-file src="src/android/res/drawable-hdpi/ic_action_next_item.png" target="res/drawable-hdpi/ic_action_next_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-mdpi/ic_action_next_item.png" target="res/drawable-mdpi/ic_action_next_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xhdpi/ic_action_next_item.png" target="res/drawable-xhdpi/ic_action_next_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_next_item.png" target="res/drawable-xxhdpi/ic_action_next_item.png" />
|
||||||
|
|
||||||
|
<resource-file src="src/android/res/drawable-hdpi/ic_action_previous_item.png" target="res/drawable-hdpi/ic_action_previous_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-mdpi/ic_action_previous_item.png" target="res/drawable-mdpi/ic_action_previous_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xhdpi/ic_action_previous_item.png" target="res/drawable-xhdpi/ic_action_previous_item.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_previous_item.png" target="res/drawable-xxhdpi/ic_action_previous_item.png" />
|
||||||
|
|
||||||
|
<resource-file src="src/android/res/drawable-hdpi/ic_action_remove.png" target="res/drawable-hdpi/ic_action_remove.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-mdpi/ic_action_remove.png" target="res/drawable-mdpi/ic_action_remove.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xhdpi/ic_action_remove.png" target="res/drawable-xhdpi/ic_action_remove.png" />
|
||||||
|
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_remove.png" target="res/drawable-xxhdpi/ic_action_remove.png" />
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
<!-- ubuntu -->
|
<!-- ubuntu -->
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
package org.apache.cordova.inappbrowser;
|
package org.apache.cordova.inappbrowser;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import org.apache.cordova.inappbrowser.InAppBrowserDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -82,7 +85,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||||
|
|
||||||
private Dialog dialog;
|
private InAppBrowserDialog dialog;
|
||||||
private AmazonWebView inAppWebView;
|
private AmazonWebView inAppWebView;
|
||||||
private EditText edittext;
|
private EditText edittext;
|
||||||
private CallbackContext callbackContext;
|
private CallbackContext callbackContext;
|
||||||
@ -256,11 +259,16 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
scriptToInject = source;
|
scriptToInject = source;
|
||||||
}
|
}
|
||||||
final String finalScriptToInject = scriptToInject;
|
final String finalScriptToInject = scriptToInject;
|
||||||
// This action will have the side-effect of blurring the currently focused element
|
|
||||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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);
|
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
|
||||||
|
} /*else {
|
||||||
|
inAppWebView.evaluateJavascript(finalScriptToInject, null);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -305,7 +313,14 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
try {
|
try {
|
||||||
Intent intent = null;
|
Intent intent = null;
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
// Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
|
||||||
|
// Adding the MIME type to http: URLs causes them to not be handled by the downloader.
|
||||||
|
Uri uri = Uri.parse(url);
|
||||||
|
if ("file".equals(uri.getScheme())) {
|
||||||
|
intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
|
||||||
|
} else {
|
||||||
|
intent.setData(uri);
|
||||||
|
}
|
||||||
this.cordova.getActivity().startActivity(intent);
|
this.cordova.getActivity().startActivity(intent);
|
||||||
return "";
|
return "";
|
||||||
} catch (android.content.ActivityNotFoundException e) {
|
} catch (android.content.ActivityNotFoundException e) {
|
||||||
@ -318,16 +333,38 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
* Closes the dialog
|
* Closes the dialog
|
||||||
*/
|
*/
|
||||||
public void closeDialog() {
|
public void closeDialog() {
|
||||||
|
final AmazonWebView childView = this.inAppWebView;
|
||||||
|
// The JS protects against multiple calls, so this should happen only when
|
||||||
|
// closeDialog() is called by other native code.
|
||||||
|
if (childView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
childView.setWebViewClient(new AmazonWebViewClient() {
|
||||||
|
// NB: wait for about:blank before dismissing
|
||||||
|
public void onPageFinished(AmazonWebView view, String url) {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// NB: From SDK 19: "If you call methods on WebView from any thread
|
||||||
|
// other than your app's UI thread, it can cause unexpected results."
|
||||||
|
// http://developer.android.com/guide/webapps/migrating.html#Threads
|
||||||
|
childView.loadUrl("about:blank");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("type", EXIT_EVENT);
|
||||||
|
sendUpdate(obj, false);
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
Log.d(LOG_TAG, "Should never happen");
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Checks to see if it is possible to go back one page in history, then does so.
|
* Checks to see if it is possible to go back one page in history, then does so.
|
||||||
*/
|
*/
|
||||||
@ -385,6 +422,10 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
return this.showLocationBar;
|
return this.showLocationBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InAppBrowser getInAppBrowser(){
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a new browser with the specified URL.
|
* Display a new browser with the specified URL.
|
||||||
*
|
*
|
||||||
@ -435,15 +476,11 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
// Let's create the main dialog
|
// Let's create the main dialog
|
||||||
dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
||||||
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
||||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
dialog.setCancelable(true);
|
dialog.setCancelable(true);
|
||||||
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
dialog.setInAppBroswer(getInAppBrowser());
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
closeDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Main container layout
|
// Main container layout
|
||||||
LinearLayout main = new LinearLayout(cordova.getActivity());
|
LinearLayout main = new LinearLayout(cordova.getActivity());
|
||||||
@ -472,7 +509,21 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
back.setLayoutParams(backLayoutParams);
|
back.setLayoutParams(backLayoutParams);
|
||||||
back.setContentDescription("Back Button");
|
back.setContentDescription("Back Button");
|
||||||
back.setId(2);
|
back.setId(2);
|
||||||
|
/*
|
||||||
back.setText("<");
|
back.setText("<");
|
||||||
|
*/
|
||||||
|
Resources activityRes = cordova.getActivity().getResources();
|
||||||
|
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
||||||
|
Drawable backIcon = activityRes.getDrawable(backResId);
|
||||||
|
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() {
|
back.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
goBack();
|
goBack();
|
||||||
@ -486,7 +537,17 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
forward.setLayoutParams(forwardLayoutParams);
|
forward.setLayoutParams(forwardLayoutParams);
|
||||||
forward.setContentDescription("Forward Button");
|
forward.setContentDescription("Forward Button");
|
||||||
forward.setId(3);
|
forward.setId(3);
|
||||||
forward.setText(">");
|
//forward.setText(">");
|
||||||
|
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
||||||
|
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
||||||
|
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() {
|
forward.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
goForward();
|
goForward();
|
||||||
@ -523,7 +584,17 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
close.setLayoutParams(closeLayoutParams);
|
close.setLayoutParams(closeLayoutParams);
|
||||||
forward.setContentDescription("Close Button");
|
forward.setContentDescription("Close Button");
|
||||||
close.setId(5);
|
close.setId(5);
|
||||||
close.setText(buttonLabel);
|
//close.setText(buttonLabel);
|
||||||
|
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
|
||||||
|
Drawable closeIcon = activityRes.getDrawable(closeResId);
|
||||||
|
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() {
|
close.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
|
Loading…
Reference in New Issue
Block a user