Added homepage button, altered tab UI slightly, fixed URL validation
@ -50,6 +50,7 @@ import android.support.v7.graphics.Palette;
|
|||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -303,24 +304,19 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
lp.height = LayoutParams.MATCH_PARENT;
|
lp.height = LayoutParams.MATCH_PARENT;
|
||||||
v.setLayoutParams(lp);
|
v.setLayoutParams(lp);
|
||||||
|
|
||||||
LinearLayout searchContainer = (LinearLayout) v.findViewById(R.id.search_container);
|
|
||||||
LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) searchContainer.getLayoutParams();
|
|
||||||
int leftMargin = !mShowTabsInDrawer ? Utils.dpToPx(10) : Utils.dpToPx(2);
|
|
||||||
p.setMargins(leftMargin, Utils.dpToPx(8), Utils.dpToPx(2), Utils.dpToPx(6));
|
|
||||||
searchContainer.setLayoutParams(p);
|
|
||||||
|
|
||||||
mArrowDrawable = new DrawerArrowDrawable(this);
|
|
||||||
mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow);
|
mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow);
|
||||||
// Use hardware acceleration for the animation
|
|
||||||
mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
mArrowImage.setImageDrawable(mArrowDrawable);
|
|
||||||
FrameLayout arrowButton = (FrameLayout) actionBar.getCustomView().findViewById(
|
FrameLayout arrowButton = (FrameLayout) actionBar.getCustomView().findViewById(
|
||||||
R.id.arrow_button);
|
R.id.arrow_button);
|
||||||
if (mShowTabsInDrawer) {
|
if (mShowTabsInDrawer) {
|
||||||
arrowButton.setOnClickListener(this);
|
// Use hardware acceleration for the animation
|
||||||
|
mArrowDrawable = new DrawerArrowDrawable(this);
|
||||||
|
mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
mArrowImage.setImageDrawable(mArrowDrawable);
|
||||||
} else {
|
} else {
|
||||||
arrowButton.setVisibility(View.GONE);
|
mArrowImage.setImageResource(R.drawable.ic_action_home);
|
||||||
|
mArrowImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
arrowButton.setOnClickListener(this);
|
||||||
|
|
||||||
mProxyUtils = ProxyUtils.getInstance(this);
|
mProxyUtils = ProxyUtils.getInstance(this);
|
||||||
|
|
||||||
@ -513,7 +509,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mArrowImage.startAnimation(anim);
|
if (mArrowDrawable != null) {
|
||||||
|
mArrowImage.startAnimation(anim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 100);
|
}, 100);
|
||||||
@ -1538,13 +1536,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
boolean validURL = (query.startsWith("ftp://") || query.startsWith(Constants.HTTP)
|
boolean validURL = (query.startsWith("ftp://") || query.startsWith(Constants.HTTP)
|
||||||
|| query.startsWith(Constants.FILE) || query.startsWith(Constants.HTTPS))
|
|| query.startsWith(Constants.FILE) || query.startsWith(Constants.HTTPS))
|
||||||
|| isIPAddress;
|
|| isIPAddress;
|
||||||
boolean isSearch = ((query.contains(" ") || !containsPeriod) && !aboutScheme);
|
|
||||||
|
|
||||||
if (isIPAddress
|
if (isIPAddress
|
||||||
&& (!query.startsWith(Constants.HTTP) || !query.startsWith(Constants.HTTPS))) {
|
&& (!query.startsWith(Constants.HTTP) || !query.startsWith(Constants.HTTPS))) {
|
||||||
query = Constants.HTTP + query;
|
query = Constants.HTTP + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validURL |= Patterns.WEB_URL.matcher(query).matches();
|
||||||
|
boolean isSearch = !validURL;
|
||||||
|
|
||||||
if (isSearch) {
|
if (isSearch) {
|
||||||
try {
|
try {
|
||||||
query = URLEncoder.encode(query, "UTF-8");
|
query = URLEncoder.encode(query, "UTF-8");
|
||||||
@ -2883,6 +2882,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
mCurrentView.requestFocus();
|
mCurrentView.requestFocus();
|
||||||
} else if (mShowTabsInDrawer) {
|
} else if (mShowTabsInDrawer) {
|
||||||
mDrawerLayout.openDrawer(mDrawerLeft);
|
mDrawerLayout.openDrawer(mDrawerLeft);
|
||||||
|
} else if (mCurrentView != null) {
|
||||||
|
mCurrentView.loadHomepage();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.new_tab_button:
|
case R.id.new_tab_button:
|
||||||
|
@ -146,13 +146,20 @@ public class LightningView {
|
|||||||
// don't load anything, the user is looking for a blank tab
|
// don't load anything, the user is looking for a blank tab
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mHomepage.startsWith("about:home")) {
|
loadHomepage();
|
||||||
mWebView.loadUrl(getHomepage());
|
}
|
||||||
} else if (mHomepage.startsWith("about:bookmarks")) {
|
}
|
||||||
mBrowserController.openBookmarkPage(mWebView);
|
|
||||||
} else {
|
public void loadHomepage() {
|
||||||
mWebView.loadUrl(mHomepage);
|
if (mWebView == null) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
if (mHomepage.startsWith("about:home")) {
|
||||||
|
mWebView.loadUrl(getHomepage());
|
||||||
|
} else if (mHomepage.startsWith("about:bookmarks")) {
|
||||||
|
mBrowserController.openBookmarkPage(mWebView);
|
||||||
|
} else {
|
||||||
|
mWebView.loadUrl(mHomepage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +270,7 @@ public class LightningView {
|
|||||||
*
|
*
|
||||||
* @param settings the WebSettings object to use, you can pass in null
|
* @param settings the WebSettings object to use, you can pass in null
|
||||||
* if you don't have a reference to them
|
* if you don't have a reference to them
|
||||||
* @param context the context in which the WebView was created
|
* @param context the context in which the WebView was created
|
||||||
*/
|
*/
|
||||||
public synchronized void initializePreferences(@Nullable WebSettings settings, Context context) {
|
public synchronized void initializePreferences(@Nullable WebSettings settings, Context context) {
|
||||||
if (settings == null && mWebView == null) {
|
if (settings == null && mWebView == null) {
|
||||||
@ -378,7 +385,7 @@ public class LightningView {
|
|||||||
* be altered by the user. Distinguish between Incognito and Regular tabs here.
|
* be altered by the user. Distinguish between Incognito and Regular tabs here.
|
||||||
*
|
*
|
||||||
* @param settings the WebSettings object to use.
|
* @param settings the WebSettings object to use.
|
||||||
* @param context the Context which was used to construct the WebView.
|
* @param context the Context which was used to construct the WebView.
|
||||||
*/
|
*/
|
||||||
private void initializeSettings(WebSettings settings, Context context) {
|
private void initializeSettings(WebSettings settings, Context context) {
|
||||||
if (API < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
if (API < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/ic_action_home.png
Normal file
After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 808 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_home.png
Normal file
After Width: | Height: | Size: 206 B |
BIN
app/src/main/res/drawable-mdpi/ic_webpage.png
Normal file
After Width: | Height: | Size: 493 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_home.png
Normal file
After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 764 B After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_home.png
Normal file
After Width: | Height: | Size: 598 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.9 KiB |
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/faviconTab"
|
android:id="@+id/faviconTab"
|
||||||
android:layout_width="24dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="7dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="7dp"
|
||||||
android:contentDescription="Favicon"
|
android:contentDescription="Favicon"
|
||||||
android:gravity="center_vertical" />
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|