Browse Source

Added homepage button, altered tab UI slightly, fixed URL validation

master
Anthony Restaino 9 years ago
parent
commit
a08d793320
  1. 15000
      app/src/LightningPlus/assets/hosts.txt
  2. 31
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 25
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  4. BIN
      app/src/main/res/drawable-hdpi/ic_action_home.png
  5. BIN
      app/src/main/res/drawable-hdpi/ic_webpage.png
  6. BIN
      app/src/main/res/drawable-mdpi/ic_action_home.png
  7. BIN
      app/src/main/res/drawable-mdpi/ic_webpage.png
  8. BIN
      app/src/main/res/drawable-xhdpi/ic_action_home.png
  9. BIN
      app/src/main/res/drawable-xhdpi/ic_webpage.png
  10. BIN
      app/src/main/res/drawable-xxhdpi/ic_action_home.png
  11. BIN
      app/src/main/res/drawable-xxhdpi/ic_webpage.png
  12. 8
      app/src/main/res/layout/tab_list_item_horizontal.xml

15000
app/src/LightningPlus/assets/hosts.txt

File diff suppressed because it is too large Load Diff

31
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -50,6 +50,7 @@ import android.support.v7.graphics.Palette; @@ -50,6 +50,7 @@ import android.support.v7.graphics.Palette;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@ -303,24 +304,19 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -303,24 +304,19 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
lp.height = LayoutParams.MATCH_PARENT;
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);
// Use hardware acceleration for the animation
mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mArrowImage.setImageDrawable(mArrowDrawable);
FrameLayout arrowButton = (FrameLayout) actionBar.getCustomView().findViewById(
R.id.arrow_button);
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 {
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);
@ -513,7 +509,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -513,7 +509,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Override
public void run() {
mArrowImage.startAnimation(anim);
if (mArrowDrawable != null) {
mArrowImage.startAnimation(anim);
}
}
}, 100);
@ -1538,13 +1536,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1538,13 +1536,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
boolean validURL = (query.startsWith("ftp://") || query.startsWith(Constants.HTTP)
|| query.startsWith(Constants.FILE) || query.startsWith(Constants.HTTPS))
|| isIPAddress;
boolean isSearch = ((query.contains(" ") || !containsPeriod) && !aboutScheme);
if (isIPAddress
&& (!query.startsWith(Constants.HTTP) || !query.startsWith(Constants.HTTPS))) {
query = Constants.HTTP + query;
}
validURL |= Patterns.WEB_URL.matcher(query).matches();
boolean isSearch = !validURL;
if (isSearch) {
try {
query = URLEncoder.encode(query, "UTF-8");
@ -2883,6 +2882,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -2883,6 +2882,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mCurrentView.requestFocus();
} else if (mShowTabsInDrawer) {
mDrawerLayout.openDrawer(mDrawerLeft);
} else if (mCurrentView != null) {
mCurrentView.loadHomepage();
}
break;
case R.id.new_tab_button:

25
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -146,13 +146,20 @@ public class LightningView { @@ -146,13 +146,20 @@ public class LightningView {
// don't load anything, the user is looking for a blank tab
}
} else {
if (mHomepage.startsWith("about:home")) {
mWebView.loadUrl(getHomepage());
} else if (mHomepage.startsWith("about:bookmarks")) {
mBrowserController.openBookmarkPage(mWebView);
} else {
mWebView.loadUrl(mHomepage);
}
loadHomepage();
}
}
public void loadHomepage() {
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 { @@ -263,7 +270,7 @@ public class LightningView {
*
* @param settings the WebSettings object to use, you can pass in null
* 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) {
if (settings == null && mWebView == null) {
@ -378,7 +385,7 @@ public class LightningView { @@ -378,7 +385,7 @@ public class LightningView {
* be altered by the user. Distinguish between Incognito and Regular tabs here.
*
* @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) {
if (API < Build.VERSION_CODES.JELLY_BEAN_MR2) {

BIN
app/src/main/res/drawable-hdpi/ic_action_home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

BIN
app/src/main/res/drawable-hdpi/ic_webpage.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 808 B

BIN
app/src/main/res/drawable-mdpi/ic_action_home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

BIN
app/src/main/res/drawable-mdpi/ic_webpage.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

BIN
app/src/main/res/drawable-xhdpi/ic_action_home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

BIN
app/src/main/res/drawable-xhdpi/ic_webpage.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
app/src/main/res/drawable-xxhdpi/ic_action_home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

BIN
app/src/main/res/drawable-xxhdpi/ic_webpage.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

8
app/src/main/res/layout/tab_list_item_horizontal.xml

@ -11,10 +11,10 @@ @@ -11,10 +11,10 @@
<ImageView
android:id="@+id/faviconTab"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:contentDescription="Favicon"
android:gravity="center_vertical" />

Loading…
Cancel
Save