diff --git a/res/layout/advanced_settings.xml b/res/layout/advanced_settings.xml
index 1de0dc5..042baeb 100644
--- a/res/layout/advanced_settings.xml
+++ b/res/layout/advanced_settings.xml
@@ -221,6 +221,40 @@
android:textColor="@color/light" />
+
+
+
+
+
+
+
+
+
Snacktory
jsoup: Java HTML Parser
MIT License
+ URL Box Contents
+
+ - Domain (default)
+ - URL
+ - Title
+
diff --git a/src/acr/browser/lightning/AboutSettingsActivity.java b/src/acr/browser/lightning/AboutSettingsActivity.java
index e51a0c6..2099b12 100644
--- a/src/acr/browser/lightning/AboutSettingsActivity.java
+++ b/src/acr/browser/lightning/AboutSettingsActivity.java
@@ -55,7 +55,7 @@ public class AboutSettingsActivity extends ActionBarActivity {
private void initialize() {
- String code = "HOLO";
+ String code = "1.0";
try {
PackageInfo p = getPackageManager().getPackageInfo(getPackageName(), 0);
diff --git a/src/acr/browser/lightning/AdvancedSettingsActivity.java b/src/acr/browser/lightning/AdvancedSettingsActivity.java
index de68714..42e32df 100644
--- a/src/acr/browser/lightning/AdvancedSettingsActivity.java
+++ b/src/acr/browser/lightning/AdvancedSettingsActivity.java
@@ -25,11 +25,12 @@ import android.widget.TextView;
public class AdvancedSettingsActivity extends ActionBarActivity {
private SharedPreferences mPreferences;
- private SharedPreferences.Editor mEditPrefs;
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
private Context mContext;
private TextView mRenderText;
+ private TextView mUrlText;
private Activity mActivity;
+ private CharSequence[] mUrlOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -37,10 +38,10 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
setContentView(R.layout.advanced_settings);
// set up ActionBar
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
@@ -48,10 +49,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
- // TODO WARNING: SharedPreferences.edit() without a corresponding
- // commit() or apply() call
- mEditPrefs = mPreferences.edit();
-
mContext = this;
mActivity = this;
initialize();
@@ -66,11 +63,14 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
private void initialize() {
RelativeLayout rAllowPopups, rAllowCookies, rAllowIncognitoCookies, rRestoreTabs;
+ LinearLayout lRenderPicker, lUrlContent;
rAllowPopups = (RelativeLayout) findViewById(R.id.rAllowPopups);
rAllowCookies = (RelativeLayout) findViewById(R.id.rAllowCookies);
rAllowIncognitoCookies = (RelativeLayout) findViewById(R.id.rAllowIncognitoCookies);
rRestoreTabs = (RelativeLayout) findViewById(R.id.rRestoreTabs);
+ lRenderPicker = (LinearLayout) findViewById(R.id.layoutRendering);
+ lUrlContent = (LinearLayout) findViewById(R.id.rUrlBarContents);
cbAllowPopups = (CheckBox) findViewById(R.id.cbAllowPopups);
cbAllowCookies = (CheckBox) findViewById(R.id.cbAllowCookies);
@@ -81,9 +81,11 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
cbAllowCookies.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
cbAllowIncognitoCookies.setChecked(mPreferences.getBoolean(
PreferenceConstants.INCOGNITO_COOKIES, false));
- cbRestoreTabs.setChecked(mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true));
+ cbRestoreTabs.setChecked(mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS,
+ true));
mRenderText = (TextView) findViewById(R.id.renderText);
+ mUrlText = (TextView) findViewById(R.id.urlText);
switch (mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0)) {
case 0:
@@ -100,166 +102,148 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
break;
}
- rAllowPopups(rAllowPopups);
- rAllowCookies(rAllowCookies);
- rAllowIncognitoCookies(rAllowIncognitoCookies);
- rRestoreTabs(rRestoreTabs);
- cbAllowPopups(cbAllowPopups);
- cbAllowCookies(cbAllowCookies);
- cbAllowIncognitoCookies(cbAllowIncognitoCookies);
- cbRestoreTabs(cbRestoreTabs);
- renderPicker();
- }
+ mUrlOptions = this.getResources().getStringArray(R.array.url_content_array);
+ int option = mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0);
+ mUrlText.setText(mUrlOptions[option]);
- private void cbAllowPopups(CheckBox view) {
- view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ LayoutClickListener listener = new LayoutClickListener();
+ CheckListener cListener = new CheckListener();
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked);
- mEditPrefs.apply();
- }
+ rAllowPopups.setOnClickListener(listener);
+ rAllowCookies.setOnClickListener(listener);
+ rAllowIncognitoCookies.setOnClickListener(listener);
+ rRestoreTabs.setOnClickListener(listener);
+ lRenderPicker.setOnClickListener(listener);
+ lUrlContent.setOnClickListener(listener);
- });
- }
+ cbAllowPopups.setOnCheckedChangeListener(cListener);
+ cbAllowCookies.setOnCheckedChangeListener(cListener);
+ cbAllowIncognitoCookies.setOnCheckedChangeListener(cListener);
+ cbRestoreTabs.setOnCheckedChangeListener(cListener);
- private void cbAllowCookies(CheckBox view) {
- view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ }
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked);
- mEditPrefs.apply();
+ private class LayoutClickListener implements OnClickListener {
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.rAllowPopups:
+ cbAllowPopups.setChecked(!cbAllowPopups.isChecked());
+ break;
+ case R.id.rAllowIncognitoCookies:
+ cbAllowIncognitoCookies.setChecked(!cbAllowIncognitoCookies.isChecked());
+ break;
+ case R.id.rAllowCookies:
+ cbAllowCookies.setChecked(!cbAllowCookies.isChecked());
+ break;
+ case R.id.rRestoreTabs:
+ cbRestoreTabs.setChecked(!cbRestoreTabs.isChecked());
+ break;
+ case R.id.layoutRendering:
+ renderPicker();
+ break;
+ case R.id.rUrlBarContents:
+ urlBoxPicker();
+ break;
}
+ }
- });
}
- private void cbAllowIncognitoCookies(CheckBox view) {
- view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked);
- mEditPrefs.apply();
+ private class CheckListener implements OnCheckedChangeListener {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ switch (buttonView.getId()) {
+ case R.id.cbAllowPopups:
+ mPreferences.edit().putBoolean(PreferenceConstants.POPUPS, isChecked).apply();
+ break;
+ case R.id.cbAllowCookies:
+ mPreferences.edit().putBoolean(PreferenceConstants.COOKIES, isChecked).apply();
+ break;
+ case R.id.cbAllowIncognitoCookies:
+ mPreferences.edit()
+ .putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked).apply();
+ break;
+ case R.id.cbRestoreTabs:
+ mPreferences.edit()
+ .putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked).apply();
+ break;
}
+ }
- });
}
- private void cbRestoreTabs(CheckBox view) {
- view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ public void renderPicker() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked);
- mEditPrefs.apply();
- }
+ AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
+ picker.setTitle(getResources().getString(R.string.rendering_mode));
+ CharSequence[] chars = { mContext.getString(R.string.name_normal),
+ mContext.getString(R.string.name_inverted),
+ mContext.getString(R.string.name_grayscale),
+ mContext.getString(R.string.name_inverted_grayscale) };
- });
- }
+ int n = mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0);
- private void rAllowPopups(RelativeLayout view) {
- view.setOnClickListener(new OnClickListener() {
+ picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
@Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- cbAllowPopups.setChecked(!cbAllowPopups.isChecked());
+ public void onClick(DialogInterface dialog, int which) {
+ mPreferences.edit().putInt(PreferenceConstants.RENDERING_MODE, which).apply();
+ switch (which) {
+ case 0:
+ mRenderText.setText(mContext.getString(R.string.name_normal));
+ break;
+ case 1:
+ mRenderText.setText(mContext.getString(R.string.name_inverted));
+ break;
+ case 2:
+ mRenderText.setText(mContext.getString(R.string.name_grayscale));
+ break;
+ case 3:
+ mRenderText.setText(mContext.getString(R.string.name_inverted_grayscale));
+ break;
+ }
}
-
});
- }
-
- private void rAllowCookies(RelativeLayout view) {
- view.setOnClickListener(new OnClickListener() {
+ picker.setNeutralButton(getResources().getString(R.string.action_ok),
+ new DialogInterface.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- cbAllowCookies.setChecked(!cbAllowCookies.isChecked());
- }
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
- });
+ }
+ });
+ picker.show();
}
- private void rAllowIncognitoCookies(RelativeLayout view) {
- view.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- cbAllowIncognitoCookies.setChecked(!cbAllowIncognitoCookies.isChecked());
- }
+ public void urlBoxPicker() {
- });
+ AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
+ picker.setTitle(getResources().getString(R.string.url_contents));
- }
+ int n = mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0);
- private void rRestoreTabs(RelativeLayout view) {
- view.setOnClickListener(new OnClickListener() {
+ picker.setSingleChoiceItems(mUrlOptions, n, new DialogInterface.OnClickListener() {
@Override
- public void onClick(View v) {
- cbRestoreTabs.setChecked(!cbRestoreTabs.isChecked());
+ public void onClick(DialogInterface dialog, int which) {
+ mPreferences.edit().putInt(PreferenceConstants.URL_BOX_CONTENTS, which).apply();
+ if (which < mUrlOptions.length) {
+ mUrlText.setText(mUrlOptions[which]);
+ }
}
-
});
- }
-
- public void renderPicker() {
- LinearLayout layout = (LinearLayout) findViewById(R.id.layoutRendering);
- layout.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
- picker.setTitle(getResources().getString(R.string.rendering_mode));
- CharSequence[] chars = { mContext.getString(R.string.name_normal),
- mContext.getString(R.string.name_inverted),
- mContext.getString(R.string.name_grayscale),
- mContext.getString(R.string.name_inverted_grayscale) };
-
- int n = mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0);
-
- picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
+ picker.setNeutralButton(getResources().getString(R.string.action_ok),
+ new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- mEditPrefs.putInt(PreferenceConstants.RENDERING_MODE, which).apply();
- switch (which) {
- case 0:
- mRenderText.setText(mContext.getString(R.string.name_normal));
- break;
- case 1:
- mRenderText.setText(mContext.getString(R.string.name_inverted));
- break;
- case 2:
- mRenderText.setText(mContext.getString(R.string.name_grayscale));
- break;
- case 3:
- mRenderText.setText(mContext
- .getString(R.string.name_inverted_grayscale));
- break;
- }
+
}
});
- picker.setNeutralButton(getResources().getString(R.string.action_ok),
- new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- }
- });
- picker.show();
- }
-
- });
+ picker.show();
}
- public void importFromStockBrowser() {
- BookmarkManager manager = new BookmarkManager(this);
- manager.importBookmarksFromBrowser();
- }
}
diff --git a/src/acr/browser/lightning/BrowserActivity.java b/src/acr/browser/lightning/BrowserActivity.java
index 70901af..2d77a86 100644
--- a/src/acr/browser/lightning/BrowserActivity.java
+++ b/src/acr/browser/lightning/BrowserActivity.java
@@ -11,8 +11,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.*;
-import android.content.res.Resources.Theme;
-import android.content.res.TypedArray;
+import android.content.res.Configuration;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
@@ -37,7 +36,6 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.text.TextUtils;
import android.util.Log;
-import android.util.TypedValue;
import android.view.*;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
@@ -97,7 +95,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
private ValueCallback mUploadMessage;
private View mCustomView;
private int mOriginalOrientation;
- private int mActionBarSize;
private ActionBar mActionBar;
private boolean mFullScreen;
private boolean mColorMode;
@@ -113,10 +110,10 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
private LinearLayout mToolbarLayout;
private HistoryDatabaseHandler mHistoryHandler;
private SharedPreferences mPreferences;
- private SharedPreferences.Editor mEditPrefs;
private Context mContext;
private Bitmap mWebpageBitmap;
private String mSearchText;
+ private String mUntitledTitle;
private Activity mActivity;
private final int API = android.os.Build.VERSION.SDK_INT;
private Drawable mDeleteIcon;
@@ -144,11 +141,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
- TypedValue typedValue = new TypedValue();
- Theme theme = getTheme();
- theme.resolveAttribute(R.attr.numberColor, typedValue, true);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
- mEditPrefs = mPreferences.edit();
mContext = this;
if (mWebViews != null) {
mWebViews.clear();
@@ -159,7 +152,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
if (!mPreferences.getBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, false)) {
List old = Utils.getOldBookmarks(this);
mBookmarkManager.addBookmarkList(old);
- mEditPrefs.putBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, true).apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.OLD_BOOKMARKS_IMPORTED, true)
+ .apply();
}
mActivity = this;
mClickHandler = new ClickHandler(this);
@@ -168,8 +162,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mPageLayout = (LinearLayout) findViewById(R.id.main_layout);
mUiLayout = (LinearLayout) findViewById(R.id.ui_layout);
mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view);
- // mProgressBar.setVisibility(View.GONE);
- // TODO
mNewTab = (RelativeLayout) findViewById(R.id.new_tab_button);
mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer);
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Drawer
@@ -190,13 +182,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mWebpageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_webpage);
mActionBar = getSupportActionBar();
- final TypedArray styledAttributes = mContext.getTheme().obtainStyledAttributes(
- new int[] { android.R.attr.actionBarSize });
- mActionBarSize = (int) styledAttributes.getDimension(0, 0);
- if (pixelsToDp(mActionBarSize) < 48) {
- mActionBarSize = Utils.convertDpiToPixels(mContext, 48);
- }
- styledAttributes.recycle();
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
@@ -211,9 +196,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener());
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
- if (mHistoryHandler == null) {
- mHistoryHandler = new HistoryDatabaseHandler(this);
- } else if (!mHistoryHandler.isOpen()) {
+ if (mHistoryHandler == null || !mHistoryHandler.isOpen()) {
mHistoryHandler = new HistoryDatabaseHandler(this);
}
@@ -293,15 +276,16 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
// create the search EditText in the ToolBar
mSearch = (AutoCompleteTextView) mActionBar.getCustomView().findViewById(R.id.search);
+ mUntitledTitle = (String) this.getString(R.string.untitled);
mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete);
- mDeleteIcon.setBounds(0, 0, Utils.convertDpiToPixels(mContext, 24),
- Utils.convertDpiToPixels(mContext, 24));
+ mDeleteIcon.setBounds(0, 0, Utils.convertDpToPixels(24),
+ Utils.convertDpToPixels(24));
mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh);
- mRefreshIcon.setBounds(0, 0, Utils.convertDpiToPixels(mContext, 24),
- Utils.convertDpiToPixels(mContext, 24));
+ mRefreshIcon.setBounds(0, 0, Utils.convertDpToPixels(24),
+ Utils.convertDpToPixels(24));
mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy);
- mCopyIcon.setBounds(0, 0, Utils.convertDpiToPixels(mContext, 24),
- Utils.convertDpiToPixels(mContext, 24));
+ mCopyIcon.setBounds(0, 0, Utils.convertDpToPixels(24),
+ Utils.convertDpToPixels(24));
mIcon = mRefreshIcon;
SearchClass search = new SearchClass();
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
@@ -339,7 +323,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
newTab(url, true);
Toast.makeText(mContext, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
}
- mEditPrefs.putString(PreferenceConstants.SAVE_URL, null).apply();
+ mPreferences.edit().putString(PreferenceConstants.SAVE_URL, null).apply();
return true;
}
@@ -641,8 +625,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
OrbotHelper oh = new OrbotHelper(this);
if (oh.isOrbotInstalled()
&& !mPreferences.getBoolean(PreferenceConstants.INITIAL_CHECK_FOR_TOR, false)) {
- mEditPrefs.putBoolean(PreferenceConstants.INITIAL_CHECK_FOR_TOR, true);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.INITIAL_CHECK_FOR_TOR, true).apply();
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -671,8 +654,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
initializeTor();
return true;
} else {
- mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, false);
- mEditPrefs.apply();
+ mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false).apply();
return false;
}
}
@@ -697,9 +679,19 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
- public void setNavigationDrawerWidth() {
- int width = getResources().getDisplayMetrics().widthPixels * 3 / 4;
- int maxWidth = Utils.convertDpiToPixels(mContext, 300);
+ private boolean isTablet() {
+ return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+ }
+
+ private void setNavigationDrawerWidth() {
+ int width = getResources().getDisplayMetrics().widthPixels
+ - Utils.convertDpToPixels(56);
+ int maxWidth;
+ if(isTablet()){
+ maxWidth = Utils.convertDpToPixels(320);
+ } else {
+ maxWidth = Utils.convertDpToPixels(300);
+ }
if (width > maxWidth) {
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft
.getLayoutParams();
@@ -747,7 +739,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
if (mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
String mem = mPreferences.getString(PreferenceConstants.URL_MEMORY, "");
- mEditPrefs.putString(PreferenceConstants.URL_MEMORY, "").apply();
+ mPreferences.edit().putString(PreferenceConstants.URL_MEMORY, "").apply();
String[] array = Utils.getArray(mem);
int count = 0;
for (int n = 0; n < array.length; n++) {
@@ -1198,6 +1190,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
mCurrentView = view;
mCurrentView.setForegroundTab(true);
+ mCurrentView.requestFocus();
if (mCurrentView.getWebView() != null) {
updateUrl(mCurrentView.getUrl(), true);
updateProgress(mCurrentView.getProgress());
@@ -1309,7 +1302,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
return;
}
if (reference.getUrl() != null && !reference.getUrl().startsWith(Constants.FILE)) {
- mEditPrefs.putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply();
+ mPreferences.edit().putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply();
}
boolean isShown = reference.isShown();
if (current > position) {
@@ -1455,7 +1448,9 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
} else {
if (mCurrentView != null) {
Log.d(Constants.TAG, "onBackPressed");
- if (mCurrentView.canGoBack()) {
+ if (!mCurrentView.getWebView().hasFocus()) {
+ mCurrentView.requestFocus();
+ } else if (mCurrentView.canGoBack()) {
if (!mCurrentView.isShown()) {
onHideCustomView();
} else {
@@ -1495,7 +1490,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
s = s + mWebViews.get(n).getUrl() + "|$|SEPARATOR|$|";
}
}
- mEditPrefs.putString(PreferenceConstants.URL_MEMORY, s).commit();
+ mPreferences.edit().putString(PreferenceConstants.URL_MEMORY, s).apply();
}
}
@@ -1588,11 +1583,6 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
}
- private int pixelsToDp(int num) {
- float scale = getResources().getDisplayMetrics().density;
- return (int) ((num - 0.5f) / scale);
- }
-
public class LightningViewAdapter extends ArrayAdapter {
Context context;
@@ -1852,7 +1842,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
}
protected void onPostExecute(Bitmap result) {
- Bitmap fav = Utils.padFavicon(result, mContext);
+ Bitmap fav = Utils.padFavicon(result);
bmImage.setImageBitmap(fav);
mWeb.setBitmap(fav);
notifyBookmarkDataSetChanged();
@@ -1873,13 +1863,25 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
if (url == null || mSearch == null || mSearch.hasFocus()) {
return;
}
- if (shortUrl) {
- url = url.replaceFirst(Constants.HTTP, "");
- if (url.startsWith(Constants.FILE)) {
- url = "";
+ if (shortUrl && !url.startsWith(Constants.FILE)) {
+ switch (mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0)) {
+ case 0: // Default, show only the domain
+ url = url.replaceFirst(Constants.HTTP, "");
+ url = Utils.getDomainName(url);
+ mSearch.setText(url);
+ break;
+ case 1: // URL, show the entire URL
+ mSearch.setText(url);
+ break;
+ case 2: // Title, show the page's title
+ if (mCurrentView != null && !mCurrentView.getTitle().isEmpty()) {
+ mSearch.setText(mCurrentView.getTitle());
+ } else {
+ mSearch.setText(mUntitledTitle);
+ }
+ break;
}
- url = Utils.getDomainName(url);
- mSearch.setText(url);
+
} else {
if (url.startsWith(Constants.FILE)) {
url = "";
@@ -1978,8 +1980,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
c.close();
c = null;
}
- mEditPrefs.putBoolean("SystemBrowser", browserFlag);
- mEditPrefs.commit();
+ mPreferences.edit().putBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, browserFlag)
+ .apply();
return browserFlag;
}
diff --git a/src/acr/browser/lightning/BrowserController.java b/src/acr/browser/lightning/BrowserController.java
index f6736bc..f8816e6 100644
--- a/src/acr/browser/lightning/BrowserController.java
+++ b/src/acr/browser/lightning/BrowserController.java
@@ -23,7 +23,7 @@ public interface BrowserController {
public void openFileChooser(ValueCallback uploadMsg);
public void update();
-
+
public void onLongPress();
public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback);
diff --git a/src/acr/browser/lightning/GeneralSettingsActivity.java b/src/acr/browser/lightning/GeneralSettingsActivity.java
index 14ec093..e1f494c 100644
--- a/src/acr/browser/lightning/GeneralSettingsActivity.java
+++ b/src/acr/browser/lightning/GeneralSettingsActivity.java
@@ -431,7 +431,7 @@ public class GeneralSettingsActivity extends ActionBarActivity {
getDownload.setBackgroundResource(0);
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
- int padding = Utils.convertDpiToPixels(this, 10);
+ int padding = Utils.convertDpToPixels(10);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
diff --git a/src/acr/browser/lightning/LightningView.java b/src/acr/browser/lightning/LightningView.java
index e0dde12..d1ab3f4 100644
--- a/src/acr/browser/lightning/LightningView.java
+++ b/src/acr/browser/lightning/LightningView.java
@@ -70,7 +70,7 @@ public class LightningView {
mWebView = new WebView(activity);
mTitle = new Title(activity);
mAdBlock = new AdBlock(activity);
- activity.getPackageName();
+
mWebpageBitmap = BitmapFactory.decodeResource(activity.getResources(),
R.drawable.ic_webpage);
@@ -101,41 +101,7 @@ public class LightningView {
mWebView.setWebViewClient(new LightningWebClient(activity));
mWebView.setDownloadListener(new LightningDownloadListener(activity));
mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
- mWebView.setOnTouchListener(new OnTouchListener() {
-
- float mLocation;
-
- float mY;
-
- int mAction;
-
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public boolean onTouch(View view, MotionEvent arg1) {
- if (view != null && !view.hasFocus()) {
- view.requestFocus();
- }
- mAction = arg1.getAction();
- mY = arg1.getY();
- if (mAction == MotionEvent.ACTION_DOWN) {
- mLocation = mY;
- } else if (mAction == MotionEvent.ACTION_UP) {
- if ((mY - mLocation) > 10) {
- if (mWebView.getScrollY() != 0) {
- mBrowserController.showActionBar();
- } else {
- mBrowserController.toggleActionBar();
- }
- } else if ((mY - mLocation) < -10) {
- mBrowserController.hideActionBar();
- }
- mLocation = 0;
- }
- mGestureDetector.onTouchEvent(arg1);
- return false;
- }
-
- });
+ mWebView.setOnTouchListener(new TouchListener());
mDefaultUserAgent = mWebView.getSettings().getUserAgentString();
mSettings = mWebView.getSettings();
initializeSettings(mWebView.getSettings(), activity);
@@ -1129,7 +1095,7 @@ public class LightningView {
if (favicon == null) {
mFavicon = mDefaultIcon;
} else {
- mFavicon = Utils.padFavicon(favicon, mActivity);
+ mFavicon = Utils.padFavicon(favicon);
}
}
@@ -1147,7 +1113,7 @@ public class LightningView {
if (favicon == null) {
mFavicon = mDefaultIcon;
} else {
- mFavicon = Utils.padFavicon(favicon, mActivity);
+ mFavicon = Utils.padFavicon(favicon);
}
}
@@ -1161,6 +1127,40 @@ public class LightningView {
}
+ private class TouchListener implements OnTouchListener {
+ float mLocation;
+
+ float mY;
+
+ int mAction;
+
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public boolean onTouch(View view, MotionEvent arg1) {
+ if (view != null && !view.hasFocus()) {
+ view.requestFocus();
+ }
+ mAction = arg1.getAction();
+ mY = arg1.getY();
+ if (mAction == MotionEvent.ACTION_DOWN) {
+ mLocation = mY;
+ } else if (mAction == MotionEvent.ACTION_UP) {
+ if ((mY - mLocation) > 10) {
+ if (mWebView.getScrollY() != 0) {
+ mBrowserController.showActionBar();
+ } else {
+ mBrowserController.toggleActionBar();
+ }
+ } else if ((mY - mLocation) < -10) {
+ mBrowserController.hideActionBar();
+ }
+ mLocation = 0;
+ }
+ mGestureDetector.onTouchEvent(arg1);
+ return false;
+ }
+ }
+
private class CustomGestureListener extends SimpleOnGestureListener {
/**
diff --git a/src/acr/browser/lightning/PreferenceConstants.java b/src/acr/browser/lightning/PreferenceConstants.java
index 5e65d1d..6568115 100644
--- a/src/acr/browser/lightning/PreferenceConstants.java
+++ b/src/acr/browser/lightning/PreferenceConstants.java
@@ -42,6 +42,7 @@ public final class PreferenceConstants {
public static final String SYNC_HISTORY = "syncHistory";
public static final String BLOCK_THIRD_PARTY = "thirdParty";
public static final String ENABLE_COLOR_MODE = "colorMode";
+ public static final String URL_BOX_CONTENTS = "urlContent";
public static final String USE_PROXY = "useProxy";
public static final String USE_PROXY_HOST = "useProxyHost";
diff --git a/src/acr/browser/lightning/SpaceTokenizer.java b/src/acr/browser/lightning/SpaceTokenizer.java
deleted file mode 100644
index f587645..0000000
--- a/src/acr/browser/lightning/SpaceTokenizer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2014 A.C.R. Development
- */
-package acr.browser.lightning;
-
-import android.widget.MultiAutoCompleteTextView.Tokenizer;
-
-public class SpaceTokenizer implements Tokenizer {
-
- @Override
- public int findTokenEnd(CharSequence text, int cursor) {
- // int i = cursor;
- // int len = text.length();
-
- /*
- * while (i < len) { if (text.charAt(i) == ' ') { return i; } else {
- * i++; } }
- */
- return text.length();
- }
-
- @Override
- public int findTokenStart(CharSequence text, int cursor) {
- int i = cursor;
-
- while (i > 0 && text.charAt(i - 1) != ' ') {
- i--;
- }
- while (i < cursor && text.charAt(i) == ' ') {
- i++;
- }
-
- return i;
- }
-
- @Override
- public CharSequence terminateToken(CharSequence text) {
- // int i = text.length();
- if (text.charAt(text.length() - 1) != ' ') {
- text = text + " ";
- }
- return text;
- /*
- * while (i > 0 && text.charAt(i - 1) == ' ') { i--; }
- *
- * if (i > 0 && text.charAt(i - 1) == ' ') { return text; } else { if
- * (text instanceof Spanned) { SpannableString sp = new
- * SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text,
- * 0, text.length(), Object.class, sp, 0); return sp; } else { return
- * text + " "; } }
- */
- }
-}
diff --git a/src/acr/browser/lightning/Utils.java b/src/acr/browser/lightning/Utils.java
index cda3824..11ef64a 100644
--- a/src/acr/browser/lightning/Utils.java
+++ b/src/acr/browser/lightning/Utils.java
@@ -8,9 +8,11 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.webkit.URLUtil;
import android.widget.Toast;
@@ -67,9 +69,9 @@ public final class Utils {
/**
* Returns the number of pixels corresponding to the passed density pixels
*/
- public static int convertDpiToPixels(Context context, int densityPixels) {
- float scale = context.getResources().getDisplayMetrics().density;
- return (int) (densityPixels * scale + 0.5f);
+ public static int convertDpToPixels(int dp) {
+ DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
+ return (int) (dp * metrics.density + 0.5f);
}
public static String getDomainName(String url) {
@@ -160,8 +162,8 @@ public final class Utils {
* is the bitmap to pad.
* @return the padded bitmap.
*/
- public static Bitmap padFavicon(Bitmap bitmap, Context context) {
- int padding = Utils.convertDpiToPixels(context, 4);
+ public static Bitmap padFavicon(Bitmap bitmap) {
+ int padding = Utils.convertDpToPixels(4);
Bitmap paddedBitmap = Bitmap.createBitmap(bitmap.getWidth() + padding, bitmap.getHeight()
+ padding, Bitmap.Config.ARGB_8888);