private ActionBar actionBar;
private LinearLayout findOnPageLinearLayout;
private LinearLayout tabsLinearLayout;
private ActionBar actionBar;
private LinearLayout findOnPageLinearLayout;
private LinearLayout tabsLinearLayout;
actionBar.setCustomView(R.layout.url_app_bar);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.url_app_bar);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
// Create the hamburger icon at the start of the AppBar.
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_navigation_drawer, R.string.close_navigation_drawer);
// Create the hamburger icon at the start of the AppBar.
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_navigation_drawer, R.string.close_navigation_drawer);
// Toggle the stored status of swipe to refresh.
currentWebView.setSwipeToRefresh(!currentWebView.getSwipeToRefresh());
// Toggle the stored status of swipe to refresh.
currentWebView.setSwipeToRefresh(!currentWebView.getSwipeToRefresh());
// Update the swipe refresh layout.
if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
// Update the swipe refresh layout.
if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
- public void onSaveBookmarkFolder(DialogFragment dialogFragment, int selectedFolderDatabaseId, Bitmap favoriteIconBitmap) {
+ public void onSaveBookmarkFolder(DialogFragment dialogFragment, int selectedFolderDatabaseId, @NonNull Bitmap favoriteIconBitmap) {
// Remove the incorrect lint warning below that the dialog fragment might be null.
assert dialogFragment != null;
// Remove the incorrect lint warning below that the dialog fragment might be null.
assert dialogFragment != null;
// Get the text from urlTextBox and convert it to a string. trim() removes white spaces from the beginning and end of the string.
String unformattedUrlString = urlEditText.getText().toString().trim();
// Get the text from urlTextBox and convert it to a string. trim() removes white spaces from the beginning and end of the string.
String unformattedUrlString = urlEditText.getText().toString().trim();
saveWebpageUrl = originalUrlString;
} else {
// Get the URL from the edit text, which may have been modified.
saveWebpageUrl = originalUrlString;
} else {
// Get the URL from the edit text, which may have been modified.
// Remove the formatting from the URL edit text when the user is editing the text.
urlEditText.setOnFocusChangeListener((View v, boolean hasFocus) -> {
if (hasFocus) { // The user is editing the URL text box.
// Remove the formatting from the URL edit text when the user is editing the text.
urlEditText.setOnFocusChangeListener((View v, boolean hasFocus) -> {
if (hasFocus) { // The user is editing the URL text box.
// Initialize the user agent array adapter and string array.
ArrayAdapter<CharSequence> userAgentNamesArray = ArrayAdapter.createFromResource(this, R.array.user_agent_names, R.layout.spinner_item);
String[] userAgentDataArray = getResources().getStringArray(R.array.user_agent_data);
// Initialize the user agent array adapter and string array.
ArrayAdapter<CharSequence> userAgentNamesArray = ArrayAdapter.createFromResource(this, R.array.user_agent_names, R.layout.spinner_item);
String[] userAgentDataArray = getResources().getStringArray(R.array.user_agent_data);
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
nestedScrollWebView.setSwipeToRefresh(true);
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
nestedScrollWebView.setSwipeToRefresh(true);
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
// Update the swipe refresh layout.
if (defaultSwipeToRefresh) { // Swipe to refresh is enabled.
// Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes.
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
// Set the loading of webpage images.
nestedScrollWebView.getSettings().setLoadsImagesAutomatically(displayWebpageImages);
// Set the loading of webpage images.
nestedScrollWebView.getSettings().setLoadsImagesAutomatically(displayWebpageImages);
urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.color.transparent, null));
}
urlRelativeLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.color.transparent, null));
}
// Get the current tab number.
int currentTabNumber = tabLayout.getSelectedTabPosition();
// Delete the current tab.
tabLayout.removeTabAt(currentTabNumber);
// Get the current tab number.
int currentTabNumber = tabLayout.getSelectedTabPosition();
// Delete the current tab.
tabLayout.removeTabAt(currentTabNumber);
- // Delete the current page. If the selected page number did not change during the delete, it will return true, meaning that the current WebView must be reset.
+ // Delete the current page. If the selected page number did not change during the delete (because the newly selected tab has has same number as the previously deleted tab), it will return true,
+ // meaning that the current WebView must be reset. Otherwise it will happen automatically as the selected tab number changes.
if (webViewPagerAdapter.deletePage(currentTabNumber, webViewPager)) {
setCurrentWebView(currentTabNumber);
}
if (webViewPagerAdapter.deletePage(currentTabNumber, webViewPager)) {
setCurrentWebView(currentTabNumber);
}
// Get the WebView tab fragment.
WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(i);
// Get the WebView tab fragment.
WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(i);
- // Get handles for the URL views.
- RelativeLayout urlRelativeLayout = findViewById(R.id.url_relativelayout);
- EditText urlEditText = findViewById(R.id.url_edittext);
- SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swiperefreshlayout);
-
WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(pageNumber);
// Get the fragment view.
WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(pageNumber);
// Get the fragment view.
// Update the status of swipe to refresh.
if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled.
// Enable the swipe refresh layout if the WebView is scrolled all the way to the top. It is updated every time the scroll changes.
// Update the status of swipe to refresh.
if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled.
// Enable the swipe refresh layout if the WebView is scrolled all the way to the top. It is updated every time the scroll changes.
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);
} else { // Swipe to refresh is disabled.
// Disable the swipe refresh layout.
swipeRefreshLayout.setEnabled(false);