Fix merge conflict
This commit is contained in:
commit
3a95aea82f
@ -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" />
|
||||
|
@ -187,7 +187,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
LightningDialogBuilder bookmarksDialogBuilder;
|
||||
|
||||
@Inject
|
||||
TabsManager tabsManager;
|
||||
TabsManager mTabsManager;
|
||||
|
||||
// Preference manager was moved on ThemeableBrowserActivity
|
||||
|
||||
@ -346,7 +346,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
|
||||
}
|
||||
|
||||
tabsManager.restoreTabsAndHandleIntent(this, getIntent(), isIncognito());
|
||||
mTabsManager.restoreTabsAndHandleIntent(this, getIntent(), isIncognito());
|
||||
// At this point we always have at least a tab in the tab manager
|
||||
showTab(0);
|
||||
|
||||
@ -363,7 +363,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
|
||||
searchTheWeb(mSearch.getText().toString());
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
if (currentView != null) {
|
||||
currentView.requestFocus();
|
||||
}
|
||||
@ -386,7 +386,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
|
||||
searchTheWeb(mSearch.getText().toString());
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
if (currentView != null) {
|
||||
currentView.requestFocus();
|
||||
}
|
||||
@ -397,13 +397,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, final boolean hasFocus) {
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
if (!hasFocus && currentView != null) {
|
||||
setIsLoading(currentView.getProgress() < 100);
|
||||
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);
|
||||
@ -553,8 +553,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
|
||||
private void initializePreferences() {
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final WebView currentWebView = tabsManager.getCurrentWebView();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
final WebView currentWebView = mTabsManager.getCurrentWebView();
|
||||
mFullScreen = mPreferences.getFullScreenEnabled();
|
||||
boolean colorMode = mPreferences.getColorModeEnabled();
|
||||
colorMode &= !mDarkTheme;
|
||||
@ -665,7 +665,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
// Handle action buttons
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
@ -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()));
|
||||
}
|
||||
@ -761,7 +761,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
|
||||
private void showSearchInterfaceBar(String text) {
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
if (currentView != null) {
|
||||
currentView.find(text);
|
||||
}
|
||||
@ -815,9 +815,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
* @param position the poition of the tab to display
|
||||
*/
|
||||
private synchronized void showTab(final int position) {
|
||||
final LightningView currentView = tabsManager.getCurrentTab();
|
||||
final LightningView currentView = mTabsManager.getCurrentTab();
|
||||
final WebView currentWebView = currentView != null ? currentView.getWebView() : null;
|
||||
final LightningView newView = tabsManager.switchToTab(position);
|
||||
final LightningView newView = mTabsManager.switchToTab(position);
|
||||
final WebView newWebView = newView != null ? newView.getWebView() : null;
|
||||
if (newView == null || newWebView == null) {
|
||||
return;
|
||||
@ -825,7 +825,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
// Set the background color so the color mode color doesn't show through
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
if (newView == currentView && !currentView.isShown()) {
|
||||
if (newView == currentView && currentView.isShown()) {
|
||||
return;
|
||||
}
|
||||
mIsNewIntent = false;
|
||||
@ -845,6 +845,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
updateProgress(0);
|
||||
}
|
||||
|
||||
removeViewFromParent(newWebView);
|
||||
mBrowserFrame.addView(newWebView, MATCH_PARENT);
|
||||
newView.requestFocus();
|
||||
newView.onResume();
|
||||
@ -891,32 +892,53 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
}
|
||||
|
||||
void handleNewIntent(Intent intent) {
|
||||
private static void removeViewFromParent(View view) {
|
||||
ViewGroup parent = ((ViewGroup) view.getParent());
|
||||
if (parent != null) {
|
||||
parent.removeView(view);
|
||||
}
|
||||
}
|
||||
|
||||
String url = null;
|
||||
void handleNewIntent(Intent intent) {
|
||||
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)
|
||||
.setTitle(R.string.title_warning)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadUrlInCurrentView(final String url) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab == null) {
|
||||
// This is a problem, probably an assert will be better than a return
|
||||
return;
|
||||
@ -928,7 +950,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public void closeEmptyTab() {
|
||||
final WebView currentWebView = tabsManager.getCurrentWebView();
|
||||
final WebView currentWebView = mTabsManager.getCurrentWebView();
|
||||
if (currentWebView != null && currentWebView.copyBackForwardList().getSize() == 0) {
|
||||
closeCurrentTab();
|
||||
}
|
||||
@ -942,25 +964,25 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
public void onTrimMemory(int level) {
|
||||
if (level > TRIM_MEMORY_MODERATE && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
Log.d(Constants.TAG, "Low Memory, Free Memory");
|
||||
tabsManager.freeMemory();
|
||||
mTabsManager.freeMemory();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized boolean newTab(String url, boolean show) {
|
||||
// Limit number of tabs for limited version of app
|
||||
if (!Constants.FULL_VERSION && tabsManager.size() >= 10) {
|
||||
if (!Constants.FULL_VERSION && mTabsManager.size() >= 10) {
|
||||
Utils.showSnackbar(this, R.string.max_tabs);
|
||||
return false;
|
||||
}
|
||||
mIsNewIntent = false;
|
||||
LightningView startingTab = tabsManager.newTab(this, url, isIncognito());
|
||||
LightningView startingTab = mTabsManager.newTab(this, url, isIncognito());
|
||||
if (mIdGenerator == 0) {
|
||||
startingTab.resumeTimers();
|
||||
}
|
||||
mIdGenerator++;
|
||||
|
||||
if (show) {
|
||||
showTab(tabsManager.size() - 1);
|
||||
showTab(mTabsManager.size() - 1);
|
||||
}
|
||||
// TODO Check is this is callable directly from LightningView
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
@ -969,7 +991,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
// new Handler().postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// mDrawerListLeft.smoothScrollToPosition(tabsManager.size() - 1);
|
||||
// mDrawerListLeft.smoothScrollToPosition(mTabsManager.size() - 1);
|
||||
// }
|
||||
// }, 300);
|
||||
|
||||
@ -977,16 +999,16 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
|
||||
private synchronized void deleteTab(int position) {
|
||||
final LightningView tabToDelete = tabsManager.getTabAtPosition(position);
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView tabToDelete = mTabsManager.getTabAtPosition(position);
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
|
||||
if (tabToDelete == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int current = tabsManager.positionOf(currentTab);
|
||||
int current = mTabsManager.positionOf(currentTab);
|
||||
|
||||
if (!tabToDelete.getUrl().startsWith(Constants.FILE) && !isIncognito()) {
|
||||
if (!UrlUtils.isSpecialUrl(tabToDelete.getUrl()) && !isIncognito()) {
|
||||
mPreferences.setSavedUrl(tabToDelete.getUrl());
|
||||
}
|
||||
final boolean isShown = tabToDelete.isShown();
|
||||
@ -995,30 +1017,30 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
}
|
||||
if (current > position) {
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
} else if (tabsManager.size() > position + 1) {
|
||||
} else if (mTabsManager.size() > position + 1) {
|
||||
if (current == position) {
|
||||
showTab(position + 1);
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
} else {
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
}
|
||||
} else if (tabsManager.size() > 1) {
|
||||
} else if (mTabsManager.size() > 1) {
|
||||
if (current == position) {
|
||||
showTab(position - 1);
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
} else {
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
}
|
||||
} else {
|
||||
if (currentTab != null && (currentTab.getUrl().startsWith(Constants.FILE)
|
||||
if (currentTab != null && (UrlUtils.isSpecialUrl(currentTab.getUrl())
|
||||
|| currentTab.getUrl().equals(mHomepage))) {
|
||||
closeActivity();
|
||||
} else {
|
||||
tabsManager.deleteTab(position);
|
||||
mTabsManager.deleteTab(position);
|
||||
performExitCleanUp();
|
||||
tabToDelete.pauseTimers();
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
@ -1036,7 +1058,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
|
||||
private void performExitCleanUp() {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
|
||||
WebUtils.clearCache(currentTab.getWebView());
|
||||
Log.d(Constants.TAG, "Cache Cleared");
|
||||
@ -1059,9 +1081,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
showCloseDialog(tabsManager.positionOf(currentTab));
|
||||
showCloseDialog(mTabsManager.positionOf(currentTab));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1069,14 +1091,14 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
private void closeBrowser() {
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
performExitCleanUp();
|
||||
tabsManager.shutdown();
|
||||
mTabsManager.shutdown();
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onBackPressed() {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
|
||||
mDrawerLayout.closeDrawer(mDrawerLeft);
|
||||
} else if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
|
||||
@ -1096,7 +1118,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
if (mCustomView != null || mCustomViewCallback != null) {
|
||||
onHideCustomView();
|
||||
} else {
|
||||
deleteTab(tabsManager.positionOf(currentTab));
|
||||
deleteTab(mTabsManager.positionOf(currentTab));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1109,7 +1131,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
Log.d(Constants.TAG, "onPause");
|
||||
if (currentTab != null) {
|
||||
currentTab.pauseTimers();
|
||||
@ -1129,7 +1151,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
void saveOpenTabs() {
|
||||
if (mPreferences.getRestoreLostTabsEnabled()) {
|
||||
final String s = tabsManager.tabsString();
|
||||
final String s = mTabsManager.tabsString();
|
||||
mPreferences.setMemoryUrl(s);
|
||||
}
|
||||
}
|
||||
@ -1159,7 +1181,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
Log.d(Constants.TAG, "onResume");
|
||||
if (mSearchAdapter != null) {
|
||||
mSearchAdapter.refreshPreferences();
|
||||
@ -1170,7 +1192,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
currentTab.onResume();
|
||||
}
|
||||
initializePreferences();
|
||||
tabsManager.resume(this);
|
||||
mTabsManager.resume(this);
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
|
||||
@ -1186,7 +1208,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
* checks if it is a search, url, etc.
|
||||
*/
|
||||
private void searchTheWeb(@NonNull String query) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (query.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -1271,9 +1293,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
if (url == null || mSearch == null || mSearch.hasFocus()) {
|
||||
return;
|
||||
}
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.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 +1314,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 +1342,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!url.startsWith(Constants.FILE)) {
|
||||
if (!UrlUtils.isSpecialUrl(url)) {
|
||||
new Thread(update).start();
|
||||
}
|
||||
}
|
||||
@ -1355,7 +1377,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
searchTheWeb(url);
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
currentTab.requestFocus();
|
||||
}
|
||||
@ -1522,7 +1544,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public synchronized void onShowCustomView(final View view, CustomViewCallback callback, int requestedOrientation) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (view == null || mCustomView != null) {
|
||||
if (callback != null) {
|
||||
try {
|
||||
@ -1569,7 +1591,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public void onHideCustomView() {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (mCustomView == null || mCustomViewCallback == null || currentTab == null) {
|
||||
if (mCustomViewCallback != null) {
|
||||
try {
|
||||
@ -1687,7 +1709,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
return;
|
||||
}
|
||||
if (newTab("", true)) {
|
||||
LightningView newTab = tabsManager.getTabAtPosition(tabsManager.size() - 1);
|
||||
LightningView newTab = mTabsManager.getTabAtPosition(mTabsManager.size() - 1);
|
||||
if (newTab != null) {
|
||||
final WebView webView = newTab.getWebView();
|
||||
if (webView != null) {
|
||||
@ -1709,7 +1731,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Override
|
||||
public void onCloseWindow(LightningView view) {
|
||||
deleteTab(tabsManager.positionOf(view));
|
||||
deleteTab(mTabsManager.positionOf(view));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1719,7 +1741,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Override
|
||||
public void hideActionBar() {
|
||||
final WebView currentWebView = tabsManager.getCurrentWebView();
|
||||
final WebView currentWebView = mTabsManager.getCurrentWebView();
|
||||
if (mFullScreen) {
|
||||
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
|
||||
mUiLayout.removeView(mToolbarLayout);
|
||||
@ -1759,7 +1781,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
@Override
|
||||
public void showActionBar() {
|
||||
if (mFullScreen) {
|
||||
final WebView view = tabsManager.getCurrentWebView();
|
||||
final WebView view = mTabsManager.getCurrentWebView();
|
||||
|
||||
if (mToolbarLayout == null)
|
||||
return;
|
||||
@ -1780,7 +1802,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
view.setTranslationY(height);
|
||||
}
|
||||
}
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab == null)
|
||||
return;
|
||||
|
||||
@ -1823,7 +1845,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
* See setIsFinishedLoading and setIsLoading for displaying the correct icon
|
||||
*/
|
||||
private void refreshOrStop() {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
if (currentTab.getProgress() < 100) {
|
||||
currentTab.stopLoading();
|
||||
@ -1842,7 +1864,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab == null) {
|
||||
return;
|
||||
}
|
||||
@ -1927,7 +1949,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
super.onReceive(context, intent);
|
||||
boolean isConnected = isConnected(context);
|
||||
Log.d(Constants.TAG, "Network Connected: " + String.valueOf(isConnected));
|
||||
tabsManager.notifyConnectionStatus(isConnected);
|
||||
mTabsManager.notifyConnectionStatus(isConnected);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1992,7 +2014,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void bookmarkCurrentPage(final BookmarkEvents.WantToBookmarkCurrentPage event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
mEventBus.post(new BrowserEvents.AddBookmark(currentTab.getTitle(), currentTab.getUrl()));
|
||||
}
|
||||
@ -2016,9 +2038,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void bookmarkChanged(final BookmarkEvents.BookmarkChanged event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
|
||||
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
&& currentTab.getUrl().endsWith(BookmarkPage.FILENAME)) {
|
||||
currentTab.loadBookmarkpage();
|
||||
}
|
||||
if (currentTab != null) {
|
||||
@ -2033,9 +2055,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void bookmarkDeleted(final BookmarkEvents.Deleted event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE)
|
||||
&& currentTab.getUrl().endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
&& currentTab.getUrl().endsWith(BookmarkPage.FILENAME)) {
|
||||
currentTab.loadBookmarkpage();
|
||||
}
|
||||
if (currentTab != null) {
|
||||
@ -2103,12 +2125,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void goBack(final NavigationEvents.GoBack event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
if (currentTab.canGoBack()) {
|
||||
currentTab.goBack();
|
||||
} else {
|
||||
deleteTab(tabsManager.positionOf(currentTab));
|
||||
deleteTab(mTabsManager.positionOf(currentTab));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2120,7 +2142,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void goForward(final NavigationEvents.GoForward event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
if (currentTab.canGoForward()) {
|
||||
currentTab.goForward();
|
||||
@ -2130,7 +2152,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Subscribe
|
||||
public void goHome(final NavigationEvents.GoHome event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
currentTab.loadHomepage();
|
||||
closeDrawers();
|
||||
|
@ -2,8 +2,10 @@ package acr.browser.lightning.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
|
||||
@ -13,6 +15,8 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.preference.PreferenceManager;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
import acr.browser.lightning.view.LightningView;
|
||||
@ -34,16 +38,15 @@ public class TabsManager {
|
||||
@Inject
|
||||
public TabsManager() {}
|
||||
|
||||
public void restoreTabsAndHandleIntent(Activity activity, Intent intent, boolean incognito) {
|
||||
public synchronized void restoreTabsAndHandleIntent(final Activity activity,
|
||||
final Intent intent,
|
||||
final boolean incognito) {
|
||||
String url = null;
|
||||
if (intent != null) {
|
||||
url = intent.getDataString();
|
||||
}
|
||||
mWebViewList.clear();
|
||||
mCurrentTab = null;
|
||||
if (url != null) {
|
||||
newTab(activity, url, incognito);
|
||||
}
|
||||
if (!incognito && mPreferenceManager.getRestoreLostTabsEnabled()) {
|
||||
final String mem = mPreferenceManager.getMemoryUrl();
|
||||
mPreferenceManager.setMemoryUrl("");
|
||||
@ -54,10 +57,28 @@ public class TabsManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (url != null) {
|
||||
if (url.startsWith(Constants.FILE)) {
|
||||
final String urlToLoad = url;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setCancelable(true)
|
||||
.setTitle(R.string.title_warning)
|
||||
.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(activity, urlToLoad, incognito);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} else {
|
||||
newTab(activity, url, incognito);
|
||||
}
|
||||
}
|
||||
if (mWebViewList.size() == 0) {
|
||||
newTab(activity, null, incognito);
|
||||
}
|
||||
// mCurrentTab = mWebViewList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,11 +20,16 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public final class BookmarkPage {
|
||||
|
||||
/**
|
||||
* The bookmark page standard suffix
|
||||
*/
|
||||
public static final String FILENAME = "bookmarks.html";
|
||||
|
||||
private static final String HEADING = "<!DOCTYPE html><html xmlns=http://www.w3.org/1999/xhtml>\n" +
|
||||
"<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" +
|
||||
@ -41,7 +46,7 @@ public final class BookmarkPage {
|
||||
"<p class=ellipses>\n" +
|
||||
"<img src='";
|
||||
|
||||
private static final String PART3 = "http://www.google.com/s2/favicons?domain=";
|
||||
private static final String PART3 = "https://www.google.com/s2/favicons?domain=";
|
||||
|
||||
private static final String PART4 = "' />";
|
||||
|
||||
@ -66,9 +71,9 @@ public final class BookmarkPage {
|
||||
final List<HistoryItem> list = manager.getBookmarksFromFolder(folder, true);
|
||||
final File bookmarkWebPage;
|
||||
if (folder == null || folder.isEmpty()) {
|
||||
bookmarkWebPage = new File(FILES_DIR, Constants.BOOKMARKS_FILENAME);
|
||||
bookmarkWebPage = new File(FILES_DIR, FILENAME);
|
||||
} else {
|
||||
bookmarkWebPage = new File(FILES_DIR, folder + '-' + Constants.BOOKMARKS_FILENAME);
|
||||
bookmarkWebPage = new File(FILES_DIR, folder + '-' + FILENAME);
|
||||
}
|
||||
final StringBuilder bookmarkBuilder = new StringBuilder(BookmarkPage.HEADING);
|
||||
|
||||
@ -77,7 +82,7 @@ public final class BookmarkPage {
|
||||
final HistoryItem item = list.get(n);
|
||||
bookmarkBuilder.append(BookmarkPage.PART1);
|
||||
if (item.isFolder()) {
|
||||
final File folderPage = new File(FILES_DIR, item.getTitle() + '-' + Constants.BOOKMARKS_FILENAME);
|
||||
final File folderPage = new File(FILES_DIR, item.getTitle() + '-' + FILENAME);
|
||||
bookmarkBuilder.append(Constants.FILE).append(folderPage);
|
||||
bookmarkBuilder.append(BookmarkPage.PART2);
|
||||
bookmarkBuilder.append(folderIconPath);
|
||||
|
@ -43,11 +43,6 @@ public final class Constants {
|
||||
public static final int PROXY_I2P = 2;
|
||||
public static final int PROXY_MANUAL = 3;
|
||||
|
||||
/**
|
||||
* The bookmark page standard suffix
|
||||
*/
|
||||
public static final String BOOKMARKS_FILENAME = "bookmarks.html";
|
||||
|
||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
public static final String[] TEXT_ENCODINGS = {"ISO-8859-1", "UTF-8", "GBK", "Big5", "ISO-2022-JP", "SHIFT_JS", "EUC-JP", "EUC-KR"};
|
||||
|
@ -16,7 +16,7 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public class StartPage {
|
||||
|
||||
private static final String FILENAME = "homepage.html";
|
||||
public static final String FILENAME = "homepage.html";
|
||||
|
||||
private static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
||||
+ "<head>"
|
||||
|
@ -24,6 +24,7 @@ import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BookmarkEvents;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.database.BookmarkManager;
|
||||
@ -60,11 +61,11 @@ public class LightningDialogBuilder {
|
||||
*/
|
||||
public void showLongPressedDialogForBookmarkUrl(final Context context, final String url) {
|
||||
final HistoryItem item;
|
||||
if (url.startsWith(Constants.FILE) && url.endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
if (url.startsWith(Constants.FILE) && url.endsWith(BookmarkPage.FILENAME)) {
|
||||
// TODO hacky, make a better bookmark mechanism in the future
|
||||
final Uri uri = Uri.parse(url);
|
||||
final String filename = uri.getLastPathSegment();
|
||||
final String folderTitle = filename.substring(0, filename.length() - Constants.BOOKMARKS_FILENAME.length() - 1);
|
||||
final String folderTitle = filename.substring(0, filename.length() - BookmarkPage.FILENAME.length() - 1);
|
||||
item = new HistoryItem();
|
||||
item.setIsFolder(true);
|
||||
item.setTitle(folderTitle);
|
||||
|
@ -49,6 +49,7 @@ import acr.browser.lightning.dialog.LightningDialogBuilder;
|
||||
import acr.browser.lightning.preference.PreferenceManager;
|
||||
import acr.browser.lightning.async.ImageDownloadTask;
|
||||
import acr.browser.lightning.utils.ThemeUtils;
|
||||
import acr.browser.lightning.utils.UrlUtils;
|
||||
import acr.browser.lightning.view.LightningView;
|
||||
|
||||
/**
|
||||
@ -193,12 +194,14 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
||||
@Subscribe
|
||||
public void addBookmark(final BrowserEvents.AddBookmark event) {
|
||||
final HistoryItem item = new HistoryItem(event.url, event.title);
|
||||
if (mBookmarkManager.addBookmark(item)) {
|
||||
mBookmarks.add(item);
|
||||
Collections.sort(mBookmarks, new BookmarkManager.SortIgnoreCase());
|
||||
mBookmarkAdapter.notifyDataSetChanged();
|
||||
mEventBus.post(new BookmarkEvents.Added(item));
|
||||
updateBookmarkIndicator(event.url);
|
||||
if (!UrlUtils.isSpecialUrl(item.getUrl())) {
|
||||
if (mBookmarkManager.addBookmark(item)) {
|
||||
mBookmarks.add(item);
|
||||
Collections.sort(mBookmarks, new BookmarkManager.SortIgnoreCase());
|
||||
mBookmarkAdapter.notifyDataSetChanged();
|
||||
mEventBus.post(new BookmarkEvents.Added(item));
|
||||
updateBookmarkIndicator(event.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ package acr.browser.lightning.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.CheckBoxPreference;
|
||||
@ -101,7 +102,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
||||
proxy.setSummary(mProxyChoices[choice]);
|
||||
}
|
||||
|
||||
if (API >= 19) {
|
||||
if (API >= Build.VERSION_CODES.KITKAT) {
|
||||
mPreferenceManager.setFlashSupport(0);
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
||||
boolean enableJSBool = mPreferenceManager.getJavaScriptEnabled();
|
||||
|
||||
cbAds.setEnabled(Constants.FULL_VERSION);
|
||||
cbFlash.setEnabled(API < 19);
|
||||
cbFlash.setEnabled(API < Build.VERSION_CODES.KITKAT);
|
||||
|
||||
cbImages.setChecked(imagesBool);
|
||||
cbJsScript.setChecked(enableJSBool);
|
||||
@ -343,7 +344,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
||||
if (!mHomepage.startsWith("about:")) {
|
||||
getHome.setText(mHomepage);
|
||||
} else {
|
||||
getHome.setText("http://www.google.com");
|
||||
String defaultUrl = "https://www.google.com";
|
||||
getHome.setText(defaultUrl);
|
||||
}
|
||||
homePicker.setView(getHome);
|
||||
homePicker.setPositiveButton(getResources().getString(R.string.action_ok),
|
||||
@ -526,44 +528,41 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// switch preferences
|
||||
boolean checked = false;
|
||||
if (newValue instanceof Boolean) {
|
||||
checked = (Boolean) newValue;
|
||||
}
|
||||
switch (preference.getKey()) {
|
||||
case SETTINGS_FLASH:
|
||||
if (cbFlash.isChecked()) {
|
||||
getFlashChoice();
|
||||
} else {
|
||||
mPreferenceManager.setFlashSupport(0);
|
||||
}
|
||||
if (!Utils.isFlashInstalled(mActivity) && cbFlash.isChecked()) {
|
||||
if (!Utils.isFlashInstalled(mActivity) && checked) {
|
||||
Utils.createInformativeDialog(mActivity, R.string.title_warning, R.string.dialog_adobe_not_installed);
|
||||
cbFlash.setEnabled(false);
|
||||
mPreferenceManager.setFlashSupport(0);
|
||||
return false;
|
||||
} else {
|
||||
if (checked) {
|
||||
getFlashChoice();
|
||||
} else {
|
||||
mPreferenceManager.setFlashSupport(0);
|
||||
}
|
||||
}
|
||||
cbFlash.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_ADS:
|
||||
mPreferenceManager.setAdBlockEnabled((Boolean) newValue);
|
||||
cbAds.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setAdBlockEnabled(checked);
|
||||
return true;
|
||||
case SETTINGS_IMAGES:
|
||||
mPreferenceManager.setBlockImagesEnabled((Boolean) newValue);
|
||||
cbImages.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setBlockImagesEnabled(checked);
|
||||
return true;
|
||||
case SETTINGS_JAVASCRIPT:
|
||||
mPreferenceManager.setJavaScriptEnabled((Boolean) newValue);
|
||||
cbJsScript.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setJavaScriptEnabled(checked);
|
||||
return true;
|
||||
case SETTINGS_COLORMODE:
|
||||
mPreferenceManager.setColorModeEnabled((Boolean) newValue);
|
||||
cbColorMode.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setColorModeEnabled(checked);
|
||||
return true;
|
||||
case SETTINGS_GOOGLESUGGESTIONS:
|
||||
mPreferenceManager.setGoogleSearchSuggestionsEnabled((Boolean) newValue);
|
||||
cbgooglesuggest.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setGoogleSearchSuggestionsEnabled(checked);
|
||||
return true;
|
||||
case SETTINGS_DRAWERTABS:
|
||||
mPreferenceManager.setShowTabsInDrawer((Boolean) newValue);
|
||||
cbDrawerTabs.setChecked((Boolean) newValue);
|
||||
mPreferenceManager.setShowTabsInDrawer(checked);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import android.webkit.WebView;
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
import acr.browser.lightning.utils.WebUtils;
|
||||
import acr.browser.lightning.view.LightningView;
|
||||
|
||||
public class PrivacySettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||
|
||||
@ -31,10 +32,10 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
private static final String SETTINGS_CLEARCOOKIES = "clear_cookies";
|
||||
private static final String SETTINGS_CLEARWEBSTORAGE = "clear_webstorage";
|
||||
private static final String SETTINGS_WEBSTORAGEEXIT = "clear_webstorage_exit";
|
||||
private static final String SETTINGS_DONOTTRACK = "do_not_track";
|
||||
private static final String SETTINGS_IDENTIFYINGHEADERS = "remove_identifying_headers";
|
||||
|
||||
private Activity mActivity;
|
||||
private CheckBoxPreference cblocation, cb3cookies, cbsavepasswords, cbcacheexit, cbhistoryexit,
|
||||
cbcookiesexit, cbwebstorageexit;
|
||||
private Handler messageHandler;
|
||||
|
||||
@Override
|
||||
@ -54,13 +55,15 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES);
|
||||
Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE);
|
||||
|
||||
cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
|
||||
cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
|
||||
cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
|
||||
cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
|
||||
cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
|
||||
cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
|
||||
cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
|
||||
CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
|
||||
CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
|
||||
CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
|
||||
CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
|
||||
CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
|
||||
CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
|
||||
CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
|
||||
CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK);
|
||||
CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_IDENTIFYINGHEADERS);
|
||||
|
||||
clearcache.setOnPreferenceClickListener(this);
|
||||
clearhistory.setOnPreferenceClickListener(this);
|
||||
@ -74,6 +77,8 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
cbhistoryexit.setOnPreferenceChangeListener(this);
|
||||
cbcookiesexit.setOnPreferenceChangeListener(this);
|
||||
cbwebstorageexit.setOnPreferenceChangeListener(this);
|
||||
cbDoNotTrack.setOnPreferenceChangeListener(this);
|
||||
cbIdentifyingHeaders.setOnPreferenceChangeListener(this);
|
||||
|
||||
cblocation.setChecked(mPreferenceManager.getLocationEnabled());
|
||||
cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled());
|
||||
@ -82,6 +87,11 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
|
||||
cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
|
||||
cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
|
||||
cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled());
|
||||
cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled());
|
||||
|
||||
String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
|
||||
cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);
|
||||
|
||||
cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
|
||||
|
||||
@ -194,35 +204,33 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
// switch preferences
|
||||
switch (preference.getKey()) {
|
||||
case SETTINGS_LOCATION:
|
||||
mPreferenceManager.setLocationEnabled((Boolean) newValue);
|
||||
cblocation.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_THIRDPCOOKIES:
|
||||
mPreferenceManager.setBlockThirdPartyCookiesEnabled((Boolean) newValue);
|
||||
cb3cookies.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_SAVEPASSWORD:
|
||||
mPreferenceManager.setSavePasswordsEnabled((Boolean) newValue);
|
||||
cbsavepasswords.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_CACHEEXIT:
|
||||
mPreferenceManager.setClearCacheExit((Boolean) newValue);
|
||||
cbcacheexit.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_HISTORYEXIT:
|
||||
mPreferenceManager.setClearHistoryExitEnabled((Boolean) newValue);
|
||||
cbhistoryexit.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_COOKIEEXIT:
|
||||
mPreferenceManager.setClearCookiesExitEnabled((Boolean) newValue);
|
||||
cbcookiesexit.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_WEBSTORAGEEXIT:
|
||||
mPreferenceManager.setClearWebStorageExitEnabled((Boolean) newValue);
|
||||
cbwebstorageexit.setChecked((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_DONOTTRACK:
|
||||
mPreferenceManager.setDoNotTrackEnabled((Boolean) newValue);
|
||||
return true;
|
||||
case SETTINGS_IDENTIFYINGHEADERS:
|
||||
mPreferenceManager.setRemoveIdentifyingHeadersEnabled((Boolean) newValue);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -63,6 +63,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
private final boolean mIncognito;
|
||||
private static final String CACHE_FILE_TYPE = ".sgg";
|
||||
private static final String ENCODING = "ISO-8859-1";
|
||||
private static final String DEFAULT_LANGUAGE = "en";
|
||||
private static final long INTERVAL_DAY = 86400000;
|
||||
private static final int MAX_SUGGESTIONS = 5;
|
||||
private static final SuggestionsComparator mComparator = new SuggestionsComparator();
|
||||
@ -374,9 +375,13 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
}
|
||||
InputStream in = null;
|
||||
FileOutputStream fos = null;
|
||||
String language = Locale.getDefault().getLanguage();
|
||||
if (language.isEmpty()) {
|
||||
language = DEFAULT_LANGUAGE;
|
||||
}
|
||||
try {
|
||||
URL url = new URL("http://google.com/complete/search?q=" + query
|
||||
+ "&output=toolbar&hl=en");
|
||||
URL url = new URL("https://google.com/complete/search?q=" + query
|
||||
+ "&output=toolbar&hl=" + language);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoInput(true);
|
||||
connection.connect();
|
||||
|
@ -51,6 +51,8 @@ public class PreferenceManager {
|
||||
public static final String TEXT_ENCODING = "textEncoding";
|
||||
public static final String CLEAR_WEBSTORAGE_EXIT = "clearWebStorageExit";
|
||||
public static final String SHOW_TABS_IN_DRAWER = "showTabsInDrawer";
|
||||
public static final String DO_NOT_TRACK = "doNotTrack";
|
||||
public static final String IDENTIFYING_HEADERS = "removeIdentifyingHeaders";
|
||||
|
||||
public static final String USE_PROXY = "useProxy";
|
||||
public static final String PROXY_CHOICE = "proxyChoice";
|
||||
@ -245,6 +247,14 @@ public class PreferenceManager {
|
||||
return mPrefs.getBoolean(Name.SHOW_TABS_IN_DRAWER, defaultValue);
|
||||
}
|
||||
|
||||
public boolean getDoNotTrackEnabled() {
|
||||
return mPrefs.getBoolean(Name.DO_NOT_TRACK, false);
|
||||
}
|
||||
|
||||
public boolean getRemoveIdentifyingHeadersEnabled(){
|
||||
return mPrefs.getBoolean(Name.IDENTIFYING_HEADERS, false);
|
||||
}
|
||||
|
||||
private void putBoolean(String name, boolean value) {
|
||||
mPrefs.edit().putBoolean(name, value).apply();
|
||||
}
|
||||
@ -257,6 +267,14 @@ public class PreferenceManager {
|
||||
mPrefs.edit().putString(name, value).apply();
|
||||
}
|
||||
|
||||
public void setRemoveIdentifyingHeadersEnabled(boolean enabled){
|
||||
putBoolean(Name.IDENTIFYING_HEADERS, enabled);
|
||||
}
|
||||
|
||||
public void setDoNotTrackEnabled(boolean doNotTrack) {
|
||||
putBoolean(Name.DO_NOT_TRACK, doNotTrack);
|
||||
}
|
||||
|
||||
public void setShowTabsInDrawer(boolean show) {
|
||||
putBoolean(Name.SHOW_TABS_IN_DRAWER, show);
|
||||
}
|
||||
|
@ -394,8 +394,8 @@ public class HtmlFetcher {
|
||||
if (responseCode / 100 == 3 && newUrl != null && num_redirects < 5) {
|
||||
newUrl = SPACE.matcher(newUrl).replaceAll("+");
|
||||
// some services use (none-standard) utf8 in their location header
|
||||
if (urlAsString.startsWith("http://bit.ly")
|
||||
|| urlAsString.startsWith("http://is.gd"))
|
||||
if (urlAsString.contains("://bit.ly")
|
||||
|| urlAsString.contains("://is.gd"))
|
||||
newUrl = encodeUriFromHeader(newUrl);
|
||||
|
||||
// AP: This code is not longer need, instead we always follow
|
||||
|
@ -251,8 +251,8 @@ class SHelper {
|
||||
}
|
||||
|
||||
public static String getUrlFromUglyGoogleRedirect(String url) {
|
||||
if (url.startsWith("http://www.google.com/url?")) {
|
||||
url = url.substring("http://www.google.com/url?".length());
|
||||
if (url.startsWith("https://www.google.com/url?")) {
|
||||
url = url.substring("https://www.google.com/url?".length());
|
||||
String arr[] = urlDecode(url).split("&");
|
||||
for (String str : arr) {
|
||||
if (str.startsWith("q="))
|
||||
@ -264,8 +264,8 @@ class SHelper {
|
||||
}
|
||||
|
||||
public static String getUrlFromUglyFacebookRedirect(String url) {
|
||||
if (url.startsWith("http://www.facebook.com/l.php?u=")) {
|
||||
url = url.substring("http://www.facebook.com/l.php?u=".length());
|
||||
if (url.startsWith("https://www.facebook.com/l.php?u=")) {
|
||||
url = url.substring("https://www.facebook.com/l.php?u=".length());
|
||||
return urlDecode(url);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,11 @@ import android.webkit.URLUtil;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.constant.StartPage;
|
||||
|
||||
/**
|
||||
* Utility methods for Url manipulation
|
||||
*/
|
||||
@ -145,4 +150,14 @@ 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(BookmarkPage.FILENAME) ||
|
||||
url.endsWith(HistoryPage.FILENAME) ||
|
||||
url.endsWith(StartPage.FILENAME));
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
@ -29,6 +30,9 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
import com.anthonycr.grant.PermissionsManager;
|
||||
import com.anthonycr.grant.PermissionsResultAction;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -40,8 +44,6 @@ import java.util.Date;
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.download.DownloadHandler;
|
||||
import com.anthonycr.grant.PermissionsManager;
|
||||
import com.anthonycr.grant.PermissionsResultAction;
|
||||
|
||||
public final class Utils {
|
||||
|
||||
@ -274,6 +276,24 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to close cursors. Cursor did not
|
||||
* implement Closeable until API 16, so using this
|
||||
* method for when we want to close a cursor.
|
||||
*
|
||||
* @param cursor the cursor to close
|
||||
*/
|
||||
public static void close(Cursor cursor) {
|
||||
if (cursor == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
cursor.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the trapezoid background for the horizontal tabs on a canvas object using
|
||||
* the specified color.
|
||||
|
@ -18,6 +18,7 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
@ -37,12 +38,14 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
import acr.browser.lightning.constant.HistoryPage;
|
||||
import acr.browser.lightning.constant.StartPage;
|
||||
@ -52,10 +55,15 @@ 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 {
|
||||
|
||||
public static final String HEADER_REQUESTED_WITH = "X-Requested-With";
|
||||
public static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
|
||||
public static final String HEADER_DNT = "DNT";
|
||||
|
||||
final LightningViewTitle mTitle;
|
||||
private WebView mWebView;
|
||||
final boolean mIsIncognitoTab;
|
||||
@ -78,6 +86,7 @@ public class LightningView {
|
||||
0, 0, 0, 1.0f, 0 // alpha
|
||||
};
|
||||
private final WebViewHandler mWebViewHandler = new WebViewHandler(this);
|
||||
private final Map<String, String> mRequestHeaders = new ArrayMap<>();
|
||||
|
||||
@Inject
|
||||
Bus mEventBus;
|
||||
@ -126,7 +135,7 @@ public class LightningView {
|
||||
|
||||
if (url != null) {
|
||||
if (!url.trim().isEmpty()) {
|
||||
mWebView.loadUrl(url);
|
||||
mWebView.loadUrl(url, mRequestHeaders);
|
||||
} else {
|
||||
// don't load anything, the user is looking for a blank tab
|
||||
}
|
||||
@ -140,11 +149,11 @@ public class LightningView {
|
||||
return;
|
||||
}
|
||||
if (mHomepage.startsWith("about:home")) {
|
||||
mWebView.loadUrl(StartPage.getHomepage(mActivity));
|
||||
mWebView.loadUrl(StartPage.getHomepage(mActivity), mRequestHeaders);
|
||||
} else if (mHomepage.startsWith("about:bookmarks")) {
|
||||
loadBookmarkpage();
|
||||
} else {
|
||||
mWebView.loadUrl(mHomepage);
|
||||
mWebView.loadUrl(mHomepage, mRequestHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,10 +175,10 @@ public class LightningView {
|
||||
} finally {
|
||||
Utils.close(outputStream);
|
||||
}
|
||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), Constants.BOOKMARKS_FILENAME);
|
||||
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
|
||||
|
||||
BrowserApp.getAppComponent().getBookmarkPage().buildBookmarkPage(null);
|
||||
mWebView.loadUrl(Constants.FILE + bookmarkWebPage);
|
||||
mWebView.loadUrl(Constants.FILE + bookmarkWebPage, mRequestHeaders);
|
||||
|
||||
}
|
||||
|
||||
@ -180,7 +189,7 @@ public class LightningView {
|
||||
* if you don't have a reference to them
|
||||
* @param context the context in which the WebView was created
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
|
||||
public synchronized void initializePreferences(@Nullable WebSettings settings, Context context) {
|
||||
if (settings == null && mWebView == null) {
|
||||
return;
|
||||
@ -188,6 +197,20 @@ public class LightningView {
|
||||
settings = mWebView.getSettings();
|
||||
}
|
||||
|
||||
if (mPreferences.getDoNotTrackEnabled()) {
|
||||
mRequestHeaders.put(HEADER_DNT, "1");
|
||||
} else {
|
||||
mRequestHeaders.remove(HEADER_DNT);
|
||||
}
|
||||
|
||||
if (mPreferences.getRemoveIdentifyingHeadersEnabled()) {
|
||||
mRequestHeaders.put(HEADER_REQUESTED_WITH, "");
|
||||
mRequestHeaders.put(HEADER_WAP_PROFILE, "");
|
||||
} else {
|
||||
mRequestHeaders.remove(HEADER_REQUESTED_WITH);
|
||||
mRequestHeaders.remove(HEADER_WAP_PROFILE);
|
||||
}
|
||||
|
||||
settings.setDefaultTextEncodingName(mPreferences.getTextEncoding());
|
||||
mHomepage = mPreferences.getHomepage();
|
||||
setColorMode(mPreferences.getRenderingMode());
|
||||
@ -382,6 +405,11 @@ public class LightningView {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected Map<String, String> getRequestHeaders() {
|
||||
return mRequestHeaders;
|
||||
}
|
||||
|
||||
public boolean isShown() {
|
||||
return mWebView != null && mWebView.isShown();
|
||||
}
|
||||
@ -615,7 +643,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);
|
||||
@ -623,7 +651,7 @@ public class LightningView {
|
||||
final String newUrl = result.getExtra();
|
||||
mBookmarksDialogBuilder.showLongPressedHistoryLinkDialog(mActivity, newUrl);
|
||||
}
|
||||
} else if (currentUrl.endsWith(Constants.BOOKMARKS_FILENAME)) {
|
||||
} else if (currentUrl.endsWith(BookmarkPage.FILENAME)) {
|
||||
if (url != null) {
|
||||
mBookmarksDialogBuilder.showLongPressedDialogForBookmarkUrl(mActivity, url);
|
||||
} else if (result != null && result.getExtra() != null) {
|
||||
@ -677,7 +705,7 @@ public class LightningView {
|
||||
}
|
||||
|
||||
if (mWebView != null) {
|
||||
mWebView.loadUrl(url);
|
||||
mWebView.loadUrl(url, mRequestHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +810,7 @@ public class LightningView {
|
||||
|
||||
private static class WebViewHandler extends Handler {
|
||||
|
||||
private WeakReference<LightningView> mReference;
|
||||
private final WeakReference<LightningView> mReference;
|
||||
|
||||
public WebViewHandler(LightningView view) {
|
||||
mReference = new WeakReference<>(view);
|
||||
|
@ -30,6 +30,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
@ -41,12 +42,9 @@ import acr.browser.lightning.utils.IntentUtils;
|
||||
import acr.browser.lightning.utils.ProxyUtils;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
|
||||
/**
|
||||
* @author Stefano Pacifici based on Anthony C. Restaino's code
|
||||
* @date 2015/09/22
|
||||
*/
|
||||
class LightningWebClient extends WebViewClient {
|
||||
|
||||
|
||||
private final Activity mActivity;
|
||||
private final LightningView mLightningView;
|
||||
private final UIController mUIController;
|
||||
@ -152,7 +150,6 @@ class LightningWebClient extends WebViewClient {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
handler.cancel();
|
||||
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
@ -275,13 +272,17 @@ class LightningWebClient extends WebViewClient {
|
||||
return true;
|
||||
}
|
||||
|
||||
Map<String, String> headers = mLightningView.getRequestHeaders();
|
||||
|
||||
if (mLightningView.mIsIncognitoTab) {
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
view.loadUrl(url, headers);
|
||||
return true;
|
||||
}
|
||||
if (url.startsWith("about:")) {
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
view.loadUrl(url, headers);
|
||||
return true;
|
||||
}
|
||||
if (url.contains("mailto:")) {
|
||||
if (url.startsWith("mailto:")) {
|
||||
MailTo mailTo = MailTo.parse(url);
|
||||
Intent i = Utils.newEmailIntent(mailTo.getTo(), mailTo.getSubject(),
|
||||
mailTo.getBody(), mailTo.getCc());
|
||||
@ -292,8 +293,8 @@ class LightningWebClient extends WebViewClient {
|
||||
Intent intent;
|
||||
try {
|
||||
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
|
||||
} catch (URISyntaxException ex) {
|
||||
return false;
|
||||
} catch (URISyntaxException ignored) {
|
||||
intent = null;
|
||||
}
|
||||
if (intent != null) {
|
||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||
@ -309,6 +310,10 @@ class LightningWebClient extends WebViewClient {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return mIntentUtils.startActivityForUrl(view, url);
|
||||
|
||||
if (!mIntentUtils.startActivityForUrl(view, url)) {
|
||||
view.loadUrl(url, headers);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2013 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -12,7 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
|
||||
<string name="app_name">Муња</string>
|
||||
<string name="action_new_tab">Нови језичак</string>
|
||||
@ -57,6 +60,7 @@
|
||||
<string name="action_open">Отвори</string>
|
||||
<string name="dialog_link">Шта желите да урадите са овом везом?</string>
|
||||
<string name="dialog_title_share">Подели ову страницу</string>
|
||||
<string name="dialog_history_long_press">Шта желите да урадите са овом ставком историјата?</string>
|
||||
<string name="dialog_bookmark">Шта желите да урадите са овим обележивачем?</string>
|
||||
<string name="action_delete">Обриши</string>
|
||||
<string name="action_blank">Празна страница</string>
|
||||
@ -97,7 +101,9 @@
|
||||
<string name="action_back">Назад</string>
|
||||
<string name="action_find">Нађи на страници</string>
|
||||
<string name="download_pending">Покрећем преузимање\u2026</string>
|
||||
<string name="cannot_download">Преузимање је могуће само са „http“ или „https“ адреса.</string>
|
||||
<string name="cannot_download">Могу да преузмем само са „http“ или „https“ адреса.</string>
|
||||
<string name="problem_download">Неисправан УРЛ, не могу да преузмем</string>
|
||||
<string name="problem_location_download">Не могу да преузмем у наведену локацију</string>
|
||||
<string name="download_no_sdcard_dlg_title">Нема СД картице</string>
|
||||
<string name="download_no_sdcard_dlg_msg">УСБ складиште је потребно за преузимање фајла.</string>
|
||||
<string name="download_sdcard_busy_dlg_title">УСБ складиште није доступно</string>
|
||||
@ -121,6 +127,13 @@
|
||||
<string name="licenses">Лиценце отвореног кôда</string>
|
||||
<string name="suggestion">Тражи</string>
|
||||
<string name="block_ads">Блокирај рекламе</string>
|
||||
<string name="message_insecure_connection">Веза са овим сајтом није безбедна:\n%1$s\nДа наставим свеједно?</string>
|
||||
<string name="message_certificate_date_invalid">датум сертификата је неважећи</string>
|
||||
<string name="message_certificate_expired">сертификат је истекао</string>
|
||||
<string name="message_certificate_domain_mismatch">домен на сертификату се не поклапа са доменом сајта</string>
|
||||
<string name="message_certificate_invalid">сертификат је неважећи</string>
|
||||
<string name="message_certificate_not_yet_valid">сертификат још није важећи</string>
|
||||
<string name="message_certificate_untrusted">сертификат није поуздан</string>
|
||||
<string name="title_form_resubmission">Поновно слање формулара</string>
|
||||
<string name="message_form_resubmission">Желите ли да поново пошаљете податке?</string>
|
||||
<string name="message_location">\nЖелите ли да користите вашу локацију</string>
|
||||
@ -131,8 +144,21 @@
|
||||
<string name="hint_password">Лозинка</string>
|
||||
<string name="google_suggestions">Предлози претраге</string>
|
||||
<string name="powered_by_google">Погоњено Гуглом</string>
|
||||
<string name="http_proxy">ХТТП прокси</string>
|
||||
<string-array name="proxy_choices_array">
|
||||
<item>Ништа</item>
|
||||
<item>Орбот</item>
|
||||
<item>I2P</item>
|
||||
<item>Ручно</item>
|
||||
</string-array>
|
||||
<string name="manual_proxy">Ручне поставке проксија</string>
|
||||
<string name="host">Домаћин:</string>
|
||||
<string name="port">Порт:</string>
|
||||
<string name="use_tor_prompt">Изгледа да имате Орбот инсталиран. Желите ли да користите Тор?</string>
|
||||
<string name="use_i2p_prompt">Изгледа да имате I2P инсталиран. Желите ли да користите I2P?</string>
|
||||
<string name="install_orbot">Инсталирајте Орбот да бисте користили Тор.</string>
|
||||
<string name="i2p_not_running">I2P није покренут.</string>
|
||||
<string name="i2p_tunnels_not_ready">I2P тунели још нису спремни.</string>
|
||||
<string name="yes">Да</string>
|
||||
<string name="no">Не</string>
|
||||
<string name="clear_cookies_exit">Очисти колачиће по затварању</string>
|
||||
@ -169,13 +195,14 @@
|
||||
<string name="close_all_tabs">Затвори све језичке</string>
|
||||
<string name="third_party">Блокирај колачиће треће стране</string>
|
||||
<string name="color_mode">Режим боје</string>
|
||||
<string name="reading_mode">Режим исцртавања</string>
|
||||
<string name="reading_mode">Режим за читање</string>
|
||||
<string name="loading">Учитавам…</string>
|
||||
<string name="loading_failed">Нисам могао ништа да учитам са странице.</string>
|
||||
<string name="snacktory">Snacktory</string>
|
||||
<string name="jsoup">jsoup: Јава ХТМЛ рашчлањивач</string>
|
||||
<string name="mit_license">МИТ лиценца</string>
|
||||
<string name="url_contents">Садржај УРЛ бокса</string>
|
||||
<string name="text_encoding">Кодирање текста</string>
|
||||
<string-array name="url_content_array">
|
||||
<item >Домен (подраз.)</item>
|
||||
<item >УРЛ</item>
|
||||
@ -183,5 +210,19 @@
|
||||
</string-array>
|
||||
<string name="invert_color">Обрнута боја</string>
|
||||
<string name="tabs">Језичци</string>
|
||||
<string name="dark_theme">Тамна тема</string>
|
||||
<string name="theme">Тема</string>
|
||||
<string name="light_theme">Светла</string>
|
||||
<string name="dark_theme">Тамна</string>
|
||||
<string name="black_theme">Црна (АМОЛЕД)</string>
|
||||
<string name="folder">Назив фасцикле</string>
|
||||
<string name="action_folder">Фасцикла</string>
|
||||
<string name="action_rename">Преименуј</string>
|
||||
<string name="title_rename_folder">Преименуј фасциклу</string>
|
||||
<string name="dialog_folder">Шта желите да урадите са овом фасциклом?</string>
|
||||
<string name="clear_web_storage">Очисти веб складиште</string>
|
||||
<string name="clear_web_storage_exit">Очисти веб складиште по затварању</string>
|
||||
<string name="message_web_storage_cleared">Веб складиште је очишћено</string>
|
||||
<string name="hosts_source">Извор hosts фајла за блокирање реклама</string>
|
||||
<string name="settings_adblock">Поставке Адблока</string>
|
||||
<string name="tabs_in_drawer">Језичци у фиоци навигације</string>
|
||||
</resources>
|
||||
|
@ -225,4 +225,6 @@
|
||||
<string name="hosts_source">Hosts File Ad Blocking Source</string>
|
||||
<string name="settings_adblock">Ad Block Settings</string>
|
||||
<string name="tabs_in_drawer">Show tabs in Navigation Drawer</string>
|
||||
<string name="do_not_track">Request \'Do Not Track\'</string>
|
||||
<string name="remove_identifying_headers">Remove Identifying Headers</string>
|
||||
</resources>
|
||||
|
@ -5,43 +5,51 @@
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="location"
|
||||
android:title="@string/location" />
|
||||
android:title="@string/location"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="third_party"
|
||||
android:title="@string/third_party" />
|
||||
android:title="@string/third_party"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="password"
|
||||
android:summary="@string/recommended"
|
||||
android:title="@string/password" />
|
||||
android:title="@string/password"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="do_not_track"
|
||||
android:title="@string/do_not_track"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="remove_identifying_headers"
|
||||
android:title="@string/remove_identifying_headers"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="clear_cache_exit"
|
||||
android:title="@string/cache" />
|
||||
android:title="@string/cache"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="clear_history_exit"
|
||||
android:title="@string/clear_history_exit" />
|
||||
android:title="@string/clear_history_exit"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="clear_cookies_exit"
|
||||
android:title="@string/clear_cookies_exit" />
|
||||
android:title="@string/clear_cookies_exit"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="clear_webstorage_exit"
|
||||
android:title="@string/clear_web_storage_exit" />
|
||||
android:title="@string/clear_web_storage_exit"/>
|
||||
<Preference
|
||||
android:key="clear_cache"
|
||||
android:title="@string/clear_cache" />
|
||||
android:title="@string/clear_cache"/>
|
||||
<Preference
|
||||
android:key="clear_history"
|
||||
android:title="@string/clear_history" />
|
||||
android:title="@string/clear_history"/>
|
||||
<Preference
|
||||
android:key="clear_cookies"
|
||||
android:title="@string/clear_cookies" />
|
||||
android:title="@string/clear_cookies"/>
|
||||
<Preference
|
||||
android:key="clear_webstorage"
|
||||
android:title="@string/clear_web_storage" />
|
||||
android:title="@string/clear_web_storage"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user