From fb02c90b6dc716006fa7d8fe1a6fa00ffd7757d0 Mon Sep 17 00:00:00 2001 From: Prince kushwaha Date: Wed, 18 Dec 2024 20:24:12 +0530 Subject: [PATCH] fix: click on navigation up does not close SharedDecksActivity --- .../src/main/java/com/ichi2/anki/SharedDecksActivity.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt index feda7e65a6ba..1af83ca4d860 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt @@ -32,7 +32,6 @@ import android.webkit.WebViewClient import androidx.activity.OnBackPressedCallback import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar -import androidx.core.content.ContextCompat import androidx.core.os.bundleOf import androidx.fragment.app.commit import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_INDEFINITE @@ -227,8 +226,6 @@ class SharedDecksActivity : AnkiActivity() { supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayShowHomeEnabled(true) - webviewToolbar.navigationIcon = ContextCompat.getDrawable(applicationContext, R.drawable.close_icon) - webView = findViewById(R.id.web_view) downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager @@ -283,8 +280,12 @@ class SharedDecksActivity : AnkiActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == R.id.home) { + // R.id.home refers to a custom 'home' menu item defined in your app resources (res/menu/...). shouldHistoryBeCleared = true webView.loadUrl(resources.getString(R.string.shared_decks_url)) + } else if (item.itemId == android.R.id.home) { + // android.R.id.home refers to the system-provided "up" button in the app toolbar + onBackPressedCallback.isEnabled = false } return super.onOptionsItemSelected(item) }