mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 14:23:55 +01:00
Encode the category name
This commit is contained in:
parent
75c1717c89
commit
42e2de0b51
1 changed files with 13 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
package fr.free.nrw.commons.category
|
||||
import android.util.Log
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
|
@ -199,8 +200,15 @@ class CategoryDetailsActivity : BaseActivity(),
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.menu_browser_current_category -> {
|
||||
val title = Utils.getPageTitle(CATEGORY_PREFIX + categoryName)
|
||||
Utils.handleWebUrl(this, Uri.parse(title.canonicalUri))
|
||||
// Encode the category name to ensure special characters are handled properly
|
||||
val encodedCategoryName = Uri.encode(categoryName)
|
||||
val fullUrl = "$CATEGORY_PREFIX$encodedCategoryName"
|
||||
|
||||
// Log the generated URL for debugging
|
||||
Log.d("CategoryLinkDebug", "Generated URL: $fullUrl")
|
||||
|
||||
// Handle the URL (open in a browser or WebView)
|
||||
Utils.handleWebUrl(this, Uri.parse(fullUrl))
|
||||
true
|
||||
}
|
||||
|
||||
|
|
@ -209,16 +217,19 @@ class CategoryDetailsActivity : BaseActivity(),
|
|||
viewModel.onBookmarkClick(categoryName = it)
|
||||
}
|
||||
true
|
||||
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||
menu?.run {
|
||||
val bookmarkMenuItem = findItem(R.id.menu_bookmark_current_category)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue