X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=85b3ae76e0f60987e9f86304201d246ab40e597c;hb=6ab00381e1005dbfd4e05302afa54614f96cbea1;hp=d1fb09ae8afd1bc2bb36e7586c2c5455b11c1390;hpb=83a2b6e5635956bb940642e0e5beb47453145dc3;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index d1fb09ae..85b3ae76 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -93,7 +93,6 @@ import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.ActionBar -import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.content.res.AppCompatResources @@ -349,7 +348,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook private lateinit var userAgentNamesArrayAdapter: ArrayAdapter // Define the class variables. - private var actionBarDrawerToggle: ActionBarDrawerToggle? = null private var appBarHeight = 0 private var bookmarksCursor: Cursor? = null private var bookmarksDatabaseHelper: BookmarksDatabaseHelper? = null @@ -639,9 +637,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook urlRelativeLayout = findViewById(R.id.url_relativelayout) urlEditText = findViewById(R.id.url_edittext) - // Create the hamburger icon at the start of the AppBar. - actionBarDrawerToggle = ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_navigation_drawer, R.string.close_navigation_drawer) - // Initially disable the sliding drawers. They will be enabled once the filter lists are loaded. drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) @@ -649,7 +644,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook drawerLayout.visibility = View.GONE // Initialize the WebView state adapter. - webViewStateAdapter = WebViewStateAdapter(this) + webViewStateAdapter = WebViewStateAdapter(this, bottomAppBar) // Set the pager adapter on the web view pager. webViewViewPager2.adapter = webViewStateAdapter @@ -738,15 +733,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } } - public override fun onPostCreate(savedInstanceState: Bundle?) { - // Run the default commands. - super.onPostCreate(savedInstanceState) - - // Sync the state of the DrawerToggle after the default `onRestoreInstanceState()` has finished. This creates the navigation drawer icon. - // If the app is restarting to change the app theme the action bar drawer toggle will not yet be populated. - actionBarDrawerToggle?.syncState() - } - override fun onNewIntent(intent: Intent) { // Run the default commands. super.onNewIntent(intent) @@ -1999,8 +1985,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } R.id.save_archive -> { - // Open the file picker with a default file name built from the current domain name. - saveWebpageArchiveActivityResultLauncher.launch(currentWebView!!.currentDomainName + ".mht") + // Open the file picker with a default file name built from the website title. + saveWebpageArchiveActivityResultLauncher.launch(currentWebView!!.title + ".mht") // Consume the event. true @@ -3118,7 +3104,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook fullScreenBrowsingModeEnabled = sharedPreferences.getBoolean(getString(R.string.full_screen_browsing_mode_key), false) hideAppBar = sharedPreferences.getBoolean(getString(R.string.hide_app_bar_key), true) downloadWithExternalApp = sharedPreferences.getBoolean(getString(R.string.download_with_external_app_key), false) - scrollAppBar = sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), true) + scrollAppBar = sharedPreferences.getBoolean(getString(R.string.scroll_app_bar_key), false) // Apply the saved proxy mode if the app has been restarted. if (savedProxyMode != null) { @@ -4690,10 +4676,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook override fun onDrawerOpened(drawerView: View) {} - override fun onDrawerClosed(drawerView: View) { - // Reset the drawer icon when the drawer is closed. Otherwise, it remains an arrow if the drawer is open when the app is restarted. - actionBarDrawerToggle!!.syncState() - } + override fun onDrawerClosed(drawerView: View) {} override fun onDrawerStateChanged(newState: Int) { if (newState == DrawerLayout.STATE_SETTLING || newState == DrawerLayout.STATE_DRAGGING) { // A drawer is opening or closing. @@ -6166,6 +6149,11 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook currentWebView!!.loadUrl(openFilePath) } } + // The view parameter cannot be removed because it is called from the layout onClick. + fun openNavigationDrawer(@Suppress("UNUSED_PARAMETER")view: View) { + // Open the navigation drawer. + drawerLayout.openDrawer(GravityCompat.START) + } private fun openWithApp(url: String) { // Create an open with app intent with `ACTION_VIEW`.