Fixed bug where homescreen didn't display for custom search URLS.

Fixed bug where exit button on tabs didn't work.

Fixed bug where special characters weren't properly encoded in searches

Updated homepage to be more modern and holo styled
This commit is contained in:
Anthony Restaino 2014-05-10 11:32:29 -04:00
parent d17049cc88
commit 97f86630d8
7 changed files with 74 additions and 51 deletions

Binary file not shown.

BIN
libs/android-support-v4.jar Normal file

Binary file not shown.

View File

@ -843,8 +843,10 @@ public class BrowserActivity extends Activity implements BrowserController {
Collections.sort(mBookmarkList, new SortIgnoreCase());
notifyBookmarkDataSetChanged();
if (mCurrentView != null) {
if (mCurrentView.getUrl().startsWith(Constants.FILE)
&& mCurrentView.getUrl().endsWith("bookmarks.html")) {
if (mCurrentView.getUrl()
.startsWith(Constants.FILE)
&& mCurrentView.getUrl().endsWith(
"bookmarks.html")) {
openBookmarkPage(mCurrentView.getWebView());
}
}
@ -1342,7 +1344,8 @@ public class BrowserActivity extends Activity implements BrowserController {
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
public View getView(final int position, View convertView,
ViewGroup parent) {
View row = convertView;
LightningViewHolder holder = null;
if (row == null) {
@ -1945,7 +1948,8 @@ public class BrowserActivity extends Activity implements BrowserController {
Log.i("Lightning", "onHideCustomView");
mCurrentView.setVisibility(View.VISIBLE);
mCustomView.setKeepScreenOn(false);
setFullscreen(mPreferences.getBoolean("hidestatus", false));
setFullscreen(mPreferences.getBoolean(
PreferenceConstants.HIDE_STATUS_BAR, false));
FrameLayout decor = (FrameLayout) getWindow().getDecorView();
if (decor != null) {
decor.removeView(mFullscreenContainer);
@ -2394,10 +2398,10 @@ public class BrowserActivity extends Activity implements BrowserController {
public class SortIgnoreCase implements Comparator<HistoryItem> {
public int compare(HistoryItem o1, HistoryItem o2) {
return o1.getTitle().toLowerCase(Locale.getDefault()).compareTo(
o2.getTitle().toLowerCase(Locale.getDefault()));
return o1.getTitle().toLowerCase(Locale.getDefault())
.compareTo(o2.getTitle().toLowerCase(Locale.getDefault()));
}
}
}
}

View File

@ -25,10 +25,10 @@ public class Constants {
public static final String HOMEPAGE = "about:home";
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";
public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS";
public static final String LICENSE_INTENT = "android.intent.action.LICENSE";
public static final String SETTINGS_INTENT = "android.intent.action.SETTINGS";
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.LIGHTNING_ADVANCED_SETTINGS";
public static final String LICENSE_INTENT = "android.intent.action.LIGHTNING_LICENSE";
public static final String SETTINGS_INTENT = "android.intent.action.LIGHTNING_SETTINGS";
public static final String INCOGNITO_INTENT = "android.intent.action.LIGHTNING_INCOGNITO";
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString();
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
public static final String HTTP = "http://";

View File

@ -4,20 +4,14 @@
package acr.browser.lightning;
public class HomepageVariables {
public static final String HEAD = "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
+ "<head>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
+ "<title>Homepage</title>"
+ "</head>"
+ "<style>#search_input{height:2em; width:70%;font-size:100%;padding-right:10px;padding-left:10px;vertical-align:middle;}#search_submit{font-family:'Arial';"
+ "color:#585858;height:2.5em;font-weight:bold;vertical-align:middle;}div.center{display:block;margin-left:auto; margin-right:auto;text-align:center;vertical-align:middle;}img.smaller{width:50%;}"
+ "div.fill{height:100%;}</style><body><div class=\"fill\"></br></br></br></br></br></br></br> <div class=\"center\"><img class=\"smaller\" src=\"";
public static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0\"><title>Homepage</title></head>" +
"<style>body{background:#f2f2f2;text-align:center;}#search_input{height:35px; width:100%;outline:none;border:none;font-size: 16px;background-color:transparent;}span { display: block; overflow: hidden; padding-left:5px;vertical-align:middle;}.search_bar{display:table;vertical-align:middle;width:90%;height:35px;max-width:500px;margin:0 auto;background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}#search_submit{outline:none;height:37px;float:right;color:#404040;font-size:16px;font-weight:bold;border:none;background-color:transparent;}div.center{vertical-align:middle;height:100%;width:100%;max-height:300px; position: absolute; top:0; bottom: 0; left: 0; right: 0; margin: auto;}img.smaller{width:50%;max-width:300px;}.box { vertical-align:middle;position:relative; display: block; margin: 10px;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:5px; background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}</style><body>" +
"<div class=\"center\"><img class=\"smaller\" src=\"";
public static final String MIDDLE = "\" ></br><form onsubmit=\"return search()\" ><input class=\"search\" type=\"text\" value=\"\" id=\"search_input\" ><input "
+ "type=\"submit\" id=\"search_submit\" value=\"Search\" ></form> </div></div></br></br></br></br></br></br></br></br>"
public static final String MIDDLE = "\" ></br></br><form onsubmit=\"return search()\" class=\"search_bar\"><input "
+ "type=\"submit\" id=\"search_submit\" value=\"Search\" ><span><input class=\"search\" type=\"text\" value=\"\" id=\"search_input\" ></span></form> </div>"
+ "<script type=\"text/javascript\">function "
+ "search(){if(document.getElementById(\"search_input\").value != \"\"){window.location.href = \"";
public static final String END = "\" + document.getElementById(\"search_input\").value;}return false;}</script></body></html>";
public static final String END = "\" + document.getElementById(\"search_input\").value;document.getElementById(\"search_input\").value = \"\";}return false;}</script></body></html>";
}

View File

@ -810,15 +810,17 @@ public class IncognitoActivity extends Activity implements BrowserController {
Collections.sort(mBookmarkList, new SortIgnoreCase());
notifyBookmarkDataSetChanged();
if (mCurrentView != null) {
if (mCurrentView.getUrl().startsWith(Constants.FILE)
&& mCurrentView.getUrl().endsWith("bookmarks.html")) {
if (mCurrentView.getUrl()
.startsWith(Constants.FILE)
&& mCurrentView.getUrl().endsWith(
"bookmarks.html")) {
openBookmarkPage(mCurrentView.getWebView());
}
}
}
});
homePicker.show();
}
/**
@ -1261,7 +1263,8 @@ public class IncognitoActivity extends Activity implements BrowserController {
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
public View getView(final int position, View convertView,
ViewGroup parent) {
View row = convertView;
LightningViewHolder holder = null;
@ -1284,7 +1287,7 @@ public class IncognitoActivity extends Activity implements BrowserController {
@Override
public void onClick(View view) {
deleteTab(position);
}
@ -1816,7 +1819,8 @@ public class IncognitoActivity extends Activity implements BrowserController {
Log.i("Lightning", "onHideCustomView");
mCurrentView.setVisibility(View.VISIBLE);
mCustomView.setKeepScreenOn(false);
setFullscreen(mPreferences.getBoolean("hidestatus", false));
setFullscreen(mPreferences.getBoolean(
PreferenceConstants.HIDE_STATUS_BAR, false));
FrameLayout decor = (FrameLayout) getWindow().getDecorView();
if (decor != null) {
decor.removeView(mFullscreenContainer);
@ -2265,9 +2269,9 @@ public class IncognitoActivity extends Activity implements BrowserController {
public class SortIgnoreCase implements Comparator<HistoryItem> {
public int compare(HistoryItem o1, HistoryItem o2) {
return o1.getTitle().toLowerCase(Locale.getDefault()).compareTo(
o2.getTitle().toLowerCase(Locale.getDefault()));
return o1.getTitle().toLowerCase(Locale.getDefault())
.compareTo(o2.getTitle().toLowerCase(Locale.getDefault()));
}
}
}
}

View File

@ -153,6 +153,14 @@ public class LightningView {
String home = "";
home = HomepageVariables.HEAD;
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
case 0:
// CUSTOM SEARCH
home = home + "file:///android_asset/lightning.png";
home = home + HomepageVariables.MIDDLE;
home = home
+ mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH);
break;
case 1:
// GOOGLE_SEARCH;
home = home + "file:///android_asset/google.png";
@ -242,18 +250,21 @@ public class LightningView {
}
public synchronized void initializePreferences(Context context) {
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mPreferences = context.getSharedPreferences(
PreferenceConstants.PREFERENCES, 0);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
Constants.HOMEPAGE);
mAdBlock.updatePreference();
if (mSettings == null && mWebView != null) {
mSettings = mWebView.getSettings();
} else if (mSettings == null) {
return;
}
mSettings.setGeolocationEnabled(mPreferences.getBoolean(PreferenceConstants.LOCATION,
false));
mSettings.setGeolocationEnabled(mPreferences.getBoolean(
PreferenceConstants.LOCATION, false));
if (API < 19) {
switch (mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
switch (mPreferences.getInt(
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
case 0:
mSettings.setPluginState(PluginState.OFF);
break;
@ -308,13 +319,14 @@ public class LightningView {
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
mSettings.setBlockNetworkImage(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES,
false));
mSettings.setBlockNetworkImage(mPreferences.getBoolean(
PreferenceConstants.BLOCK_IMAGES, false));
mSettings.setSupportMultipleWindows(mPreferences.getBoolean(
PreferenceConstants.POPUPS, true));
mSettings.setUseWideViewPort(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
true));
mWideViewPort = mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, true);
mSettings.setUseWideViewPort(mPreferences.getBoolean(
PreferenceConstants.USE_WIDE_VIEWPORT, true));
mWideViewPort = mPreferences.getBoolean(
PreferenceConstants.USE_WIDE_VIEWPORT, true);
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean(
PreferenceConstants.OVERVIEW_MODE, true));
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) {
@ -589,7 +601,8 @@ public class LightningView {
builder.setTitle(mActivity.getString(R.string.title_sign_in));
builder.setView(passLayout);
builder.setCancelable(true)
.setPositiveButton(mActivity.getString(R.string.title_sign_in),
.setPositiveButton(
mActivity.getString(R.string.title_sign_in),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
@ -601,7 +614,8 @@ public class LightningView {
}
})
.setNegativeButton(mActivity.getString(R.string.action_cancel),
.setNegativeButton(
mActivity.getString(R.string.action_cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
@ -630,7 +644,8 @@ public class LightningView {
builder.setMessage(
mActivity.getString(R.string.message_untrusted_certificate))
.setCancelable(true)
.setPositiveButton(mActivity.getString(R.string.action_yes),
.setPositiveButton(
mActivity.getString(R.string.action_yes),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
@ -659,10 +674,13 @@ public class LightningView {
public void onFormResubmission(WebView view, final Message dontResend,
final Message resend) {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(mActivity.getString(R.string.title_form_resubmission));
builder.setMessage(mActivity.getString(R.string.message_form_resubmission))
builder.setTitle(mActivity
.getString(R.string.title_form_resubmission));
builder.setMessage(
mActivity.getString(R.string.message_form_resubmission))
.setCancelable(true)
.setPositiveButton(mActivity.getString(R.string.action_yes),
.setPositiveButton(
mActivity.getString(R.string.action_yes),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
@ -782,9 +800,11 @@ public class LightningView {
} else {
org = origin;
}
builder.setMessage(org + mActivity.getString(R.string.message_location))
builder.setMessage(
org + mActivity.getString(R.string.message_location))
.setCancelable(true)
.setPositiveButton(mActivity.getString(R.string.action_allow),
.setPositiveButton(
mActivity.getString(R.string.action_allow),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
@ -792,7 +812,8 @@ public class LightningView {
callback.invoke(origin, true, remember);
}
})
.setNegativeButton(mActivity.getString(R.string.action_dont_allow),
.setNegativeButton(
mActivity.getString(R.string.action_dont_allow),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,