Skip to content

Commit

Permalink
fix #140
Browse files Browse the repository at this point in the history
  • Loading branch information
tcitworld committed Nov 20, 2015
1 parent 089f680 commit 67e2129
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Binary file added app/src/main/assets/ic_action_web_site.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,15 @@ blockquote {

#article h1 {
font-size: 1.2em;
margin-bottom:0px;
}

.mbm .domain {
margin-top:0px;
margin-left:0px;
}

#domainimg {
vertical-align:top;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.widget.TextView;
import android.widget.Toast;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -66,6 +67,7 @@ public class ReadArticleActivity extends BaseActionBarActivity {

private String titleText;
private String originalUrlText;
private String domainText;
private Double positionToRestore;

private Long previousArticleID;
Expand Down Expand Up @@ -141,6 +143,11 @@ public void onCreate(Bundle savedInstanceState) {
classAttr = "";
}

try {
URL url = new URL(originalUrlText);
domainText = url.getHost();
} catch (Exception ignored) {}

String htmlHeader = "<html>\n" +
"\t<head>\n" +
"\t\t<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n" +
Expand All @@ -154,6 +161,8 @@ public void onCreate(Bundle savedInstanceState) {
"\t\t\t\t\t<div id=\"article\">\n" +
"\t\t\t\t\t\t<header class=\"mbm\">\n" +
"\t\t\t\t\t\t\t<h1>" + titleText + "</h1>\n" +
"\t\t\t\t\t\t\t<img id=\"domainimg\" src=\"file:///android_asset/ic_action_web_site.png\" />\n" +
"\t\t\t\t\t\t\t<em class=\"domain\"><a href=\"" + originalUrlText + "\">" + domainText + "</a></em>\n" +
"\t\t\t\t\t\t</header>\n" +
"\t\t\t\t\t\t<article>";

Expand Down Expand Up @@ -195,7 +204,13 @@ public void run() {

@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
return openUrl(url);
if (!url.equals(originalUrlText)) {
return openUrl(url);
} else { // If we try to open current URL, do not propose to save it, directly open browser
Intent launchBrowserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(launchBrowserIntent);
return true;
}
}

public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler,
Expand Down

0 comments on commit 67e2129

Please sign in to comment.