mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +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 | package fr.free.nrw.commons.category | ||||||
|  | import android.util.Log | ||||||
| 
 | 
 | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
|  | @ -199,8 +200,15 @@ class CategoryDetailsActivity : BaseActivity(), | ||||||
|     override fun onOptionsItemSelected(item: MenuItem): Boolean { |     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||||
|         return when (item.itemId) { |         return when (item.itemId) { | ||||||
|             R.id.menu_browser_current_category -> { |             R.id.menu_browser_current_category -> { | ||||||
|                 val title = Utils.getPageTitle(CATEGORY_PREFIX + categoryName) |                 // Encode the category name to ensure special characters are handled properly | ||||||
|                 Utils.handleWebUrl(this, Uri.parse(title.canonicalUri)) |                 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 |                 true | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | @ -209,16 +217,19 @@ class CategoryDetailsActivity : BaseActivity(), | ||||||
|                     viewModel.onBookmarkClick(categoryName = it) |                     viewModel.onBookmarkClick(categoryName = it) | ||||||
|                 } |                 } | ||||||
|                 true |                 true | ||||||
|  | 
 | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             android.R.id.home -> { |             android.R.id.home -> { | ||||||
|                 onBackPressed() |                 onBackPressed() | ||||||
|                 true |                 true | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|             else -> super.onOptionsItemSelected(item) |             else -> super.onOptionsItemSelected(item) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|     override fun onPrepareOptionsMenu(menu: Menu?): Boolean { |     override fun onPrepareOptionsMenu(menu: Menu?): Boolean { | ||||||
|         menu?.run { |         menu?.run { | ||||||
|           val bookmarkMenuItem = findItem(R.id.menu_bookmark_current_category) |           val bookmarkMenuItem = findItem(R.id.menu_bookmark_current_category) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sonalyadav
						sonalyadav