commit
dc188c54e3
@ -47,6 +47,18 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="file"/>
|
||||
<data android:mimeType="text/html"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
<data android:mimeType="application/xhtml+xml"/>
|
||||
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:scheme="about" />
|
||||
|
@ -403,7 +403,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
updateUrl(currentView.getUrl(), true);
|
||||
} else if (hasFocus && currentView != null) {
|
||||
String url = currentView.getUrl();
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
if (UrlUtils.isSpecialUrl(url)) {
|
||||
mSearch.setText("");
|
||||
} else {
|
||||
mSearch.setText(url);
|
||||
@ -691,7 +691,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
overridePendingTransition(R.anim.slide_up_in, R.anim.fade_out_scale);
|
||||
return true;
|
||||
case R.id.action_share:
|
||||
if (currentView != null && !currentView.getUrl().startsWith(Constants.FILE)) {
|
||||
if (currentView != null && !UrlUtils.isSpecialUrl(currentView.getUrl())) {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, currentView.getTitle());
|
||||
@ -703,7 +703,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
openBookmarks();
|
||||
return true;
|
||||
case R.id.action_copy:
|
||||
if (currentView != null && !currentView.getUrl().startsWith(Constants.FILE)) {
|
||||
if (currentView != null && !UrlUtils.isSpecialUrl(currentView.getUrl())) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("label", currentView.getUrl());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
@ -717,7 +717,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
openHistory();
|
||||
return true;
|
||||
case R.id.action_add_bookmark:
|
||||
if (currentView != null && !currentView.getUrl().startsWith(Constants.FILE)) {
|
||||
if (currentView != null && !UrlUtils.isSpecialUrl(currentView.getUrl())) {
|
||||
mEventBus.post(new BrowserEvents.AddBookmark(currentView.getTitle(),
|
||||
currentView.getUrl()));
|
||||
}
|
||||
@ -893,24 +893,38 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
void handleNewIntent(Intent intent) {
|
||||
|
||||
String url = null;
|
||||
final String url;
|
||||
if (intent != null) {
|
||||
url = intent.getDataString();
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
int num = 0;
|
||||
String source = null;
|
||||
final String source;
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
num = intent.getExtras().getInt(getPackageName() + ".Origin");
|
||||
source = intent.getExtras().getString("SOURCE");
|
||||
} else {
|
||||
source = null;
|
||||
}
|
||||
if (num == 1) {
|
||||
loadUrlInCurrentView(url);
|
||||
} else if (url != null) {
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
Utils.showSnackbar(this, R.string.message_blocked_local);
|
||||
url = null;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setCancelable(true)
|
||||
.setMessage(R.string.message_blocked_local)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.action_open, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
newTab(url, true);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} else {
|
||||
newTab(url, true);
|
||||
}
|
||||
newTab(url, true);
|
||||
mIsNewIntent = (source == null);
|
||||
}
|
||||
}
|
||||
@ -986,7 +1000,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
int current = tabsManager.positionOf(currentTab);
|
||||
|
||||
if (!tabToDelete.getUrl().startsWith(Constants.FILE) && !isIncognito()) {
|
||||
if (!UrlUtils.isSpecialUrl(tabToDelete.getUrl()) && !isIncognito()) {
|
||||
mPreferences.setSavedUrl(tabToDelete.getUrl());
|
||||
}
|
||||
final boolean isShown = tabToDelete.isShown();
|
||||
@ -1014,7 +1028,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
tabsManager.deleteTab(position);
|
||||
}
|
||||
} else {
|
||||
if (currentTab != null && (currentTab.getUrl().startsWith(Constants.FILE)
|
||||
if (currentTab != null && (UrlUtils.isSpecialUrl(currentTab.getUrl())
|
||||
|| currentTab.getUrl().equals(mHomepage))) {
|
||||
closeActivity();
|
||||
} else {
|
||||
@ -1273,7 +1287,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
mEventBus.post(new BrowserEvents.CurrentPageUrl(url));
|
||||
if (shortUrl && !url.startsWith(Constants.FILE)) {
|
||||
if (shortUrl && !UrlUtils.isSpecialUrl(url)) {
|
||||
switch (mPreferences.getUrlBoxContentChoice()) {
|
||||
case 0: // Default, show only the domain
|
||||
url = url.replaceFirst(Constants.HTTP, "");
|
||||
@ -1292,7 +1306,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
if (UrlUtils.isSpecialUrl(url)) {
|
||||
url = "";
|
||||
}
|
||||
mSearch.setText(url);
|
||||
@ -1320,7 +1334,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!url.startsWith(Constants.FILE)) {
|
||||
if (!UrlUtils.isSpecialUrl(url)) {
|
||||
new Thread(update).start();
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public final class BookmarkPage {
|
||||
"<head>\n" +
|
||||
"<meta content=en-us http-equiv=Content-Language />\n" +
|
||||
"<meta content='text/html; charset=utf-8' http-equiv=Content-Type />\n" +
|
||||
"<meta name=viewport content='width=device-width, initial-scale=1.0'>\n" +
|
||||
"<meta name=viewport content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>\n" +
|
||||
"<title>" +
|
||||
BrowserApp.getAppContext().getString(R.string.action_bookmarks) +
|
||||
"</title>\n" +
|
||||
|
@ -21,6 +21,9 @@ import android.webkit.URLUtil;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
|
||||
/**
|
||||
* Utility methods for Url manipulation
|
||||
*/
|
||||
@ -145,4 +148,12 @@ public class UrlUtils {
|
||||
}
|
||||
return inUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given url is the bookmarks/history page or a normal website
|
||||
*/
|
||||
public static boolean isSpecialUrl(String url) {
|
||||
return url != null && url.startsWith(Constants.FILE)
|
||||
&& (url.endsWith(Constants.BOOKMARKS_FILENAME) || url.endsWith(HistoryPage.FILENAME));
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ import acr.browser.lightning.download.LightningDownloadListener;
|
||||
import acr.browser.lightning.preference.PreferenceManager;
|
||||
import acr.browser.lightning.utils.ProxyUtils;
|
||||
import acr.browser.lightning.utils.ThemeUtils;
|
||||
import acr.browser.lightning.utils.UrlUtils;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public class LightningView {
|
||||
@ -615,7 +616,7 @@ public class LightningView {
|
||||
private void longClickPage(final String url) {
|
||||
final WebView.HitTestResult result = mWebView.getHitTestResult();
|
||||
String currentUrl = mWebView.getUrl();
|
||||
if (currentUrl != null && currentUrl.startsWith(Constants.FILE)) {
|
||||
if (currentUrl != null && UrlUtils.isSpecialUrl(currentUrl)) {
|
||||
if (currentUrl.endsWith(HistoryPage.FILENAME)) {
|
||||
if (url != null) {
|
||||
mBookmarksDialogBuilder.showLongPressedHistoryLinkDialog(mActivity, url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user