CB-10937 fix stretched icons
This closes # 157
This commit is contained in:
parent
0db344327c
commit
68054819d8
@ -19,7 +19,6 @@
|
|||||||
package org.apache.cordova.inappbrowser;
|
package org.apache.cordova.inappbrowser;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import org.apache.cordova.inappbrowser.InAppBrowserDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
@ -46,8 +45,9 @@ import android.webkit.HttpAuthHandler;
|
|||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
actionButtonContainer.setId(Integer.valueOf(1));
|
actionButtonContainer.setId(Integer.valueOf(1));
|
||||||
|
|
||||||
// Back button
|
// Back button
|
||||||
Button back = new Button(cordova.getActivity());
|
ImageButton back = new ImageButton(cordova.getActivity());
|
||||||
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||||
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
|
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
|
||||||
back.setLayoutParams(backLayoutParams);
|
back.setLayoutParams(backLayoutParams);
|
||||||
@ -572,15 +572,13 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
back.setId(Integer.valueOf(2));
|
back.setId(Integer.valueOf(2));
|
||||||
Resources activityRes = cordova.getActivity().getResources();
|
Resources activityRes = cordova.getActivity().getResources();
|
||||||
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
||||||
Drawable backIcon = activityRes.getDrawable(backResId);
|
Drawable backIcon = activityRes.getDrawable(backResId, cordova.getActivity().getTheme());
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
back.setBackground(null);
|
||||||
{
|
back.setImageDrawable(backIcon);
|
||||||
back.setBackgroundDrawable(backIcon);
|
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
}
|
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||||
else
|
back.getAdjustViewBounds();
|
||||||
{
|
|
||||||
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();
|
||||||
@ -588,7 +586,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Forward button
|
// Forward button
|
||||||
Button forward = new Button(cordova.getActivity());
|
ImageButton forward = new ImageButton(cordova.getActivity());
|
||||||
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||||
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
|
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
|
||||||
forward.setLayoutParams(forwardLayoutParams);
|
forward.setLayoutParams(forwardLayoutParams);
|
||||||
@ -596,14 +594,12 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
forward.setId(Integer.valueOf(3));
|
forward.setId(Integer.valueOf(3));
|
||||||
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
||||||
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
forward.setBackground(null);
|
||||||
{
|
forward.setImageDrawable(fwdIcon);
|
||||||
forward.setBackgroundDrawable(fwdIcon);
|
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
}
|
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||||
else
|
forward.getAdjustViewBounds();
|
||||||
{
|
|
||||||
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();
|
||||||
@ -634,7 +630,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Close/Done button
|
// Close/Done button
|
||||||
Button close = new Button(cordova.getActivity());
|
ImageButton close = new ImageButton(cordova.getActivity());
|
||||||
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||||
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
close.setLayoutParams(closeLayoutParams);
|
close.setLayoutParams(closeLayoutParams);
|
||||||
@ -642,14 +638,12 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
close.setId(Integer.valueOf(5));
|
close.setId(Integer.valueOf(5));
|
||||||
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
|
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
|
||||||
Drawable closeIcon = activityRes.getDrawable(closeResId);
|
Drawable closeIcon = activityRes.getDrawable(closeResId);
|
||||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
close.setBackground(null);
|
||||||
{
|
close.setImageDrawable(closeIcon);
|
||||||
close.setBackgroundDrawable(closeIcon);
|
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
}
|
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||||
else
|
close.getAdjustViewBounds();
|
||||||
{
|
|
||||||
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();
|
||||||
@ -675,7 +669,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
|
|
||||||
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
|
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
|
||||||
String appendUserAgent = preferences.getString("AppendUserAgent", null);
|
String appendUserAgent = preferences.getString("AppendUserAgent", null);
|
||||||
|
|
||||||
if (overrideUserAgent != null) {
|
if (overrideUserAgent != null) {
|
||||||
settings.setUserAgentString(overrideUserAgent);
|
settings.setUserAgentString(overrideUserAgent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user