| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -14,9 +14,11 @@ import androidx.webkit.WebViewFeature | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.R | 
					 | 
					 | 
					 | 
					import io.legado.app.R | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.base.VMBaseActivity | 
					 | 
					 | 
					 | 
					import io.legado.app.base.VMBaseActivity | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.constant.AppConst | 
					 | 
					 | 
					 | 
					import io.legado.app.constant.AppConst | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import io.legado.app.constant.AppConst.imagePathKey | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.databinding.ActivityRssReadBinding | 
					 | 
					 | 
					 | 
					import io.legado.app.databinding.ActivityRssReadBinding | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.help.config.AppConfig | 
					 | 
					 | 
					 | 
					import io.legado.app.help.config.AppConfig | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.lib.dialogs.SelectItem | 
					 | 
					 | 
					 | 
					import io.legado.app.lib.dialogs.SelectItem | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import io.legado.app.lib.dialogs.selector | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.lib.theme.accentColor | 
					 | 
					 | 
					 | 
					import io.legado.app.lib.theme.accentColor | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.lib.theme.primaryTextColor | 
					 | 
					 | 
					 | 
					import io.legado.app.lib.theme.primaryTextColor | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.model.Download | 
					 | 
					 | 
					 | 
					import io.legado.app.model.Download | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -38,15 +40,13 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    override val binding by viewBinding(ActivityRssReadBinding::inflate) | 
					 | 
					 | 
					 | 
					    override val binding by viewBinding(ActivityRssReadBinding::inflate) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    override val viewModel by viewModels<ReadRssViewModel>() | 
					 | 
					 | 
					 | 
					    override val viewModel by viewModels<ReadRssViewModel>() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private val imagePathKey = "imagePath" | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private var starMenuItem: MenuItem? = null | 
					 | 
					 | 
					 | 
					    private var starMenuItem: MenuItem? = null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private var ttsMenuItem: MenuItem? = null | 
					 | 
					 | 
					 | 
					    private var ttsMenuItem: MenuItem? = null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private var customWebViewCallback: WebChromeClient.CustomViewCallback? = null | 
					 | 
					 | 
					 | 
					    private var customWebViewCallback: WebChromeClient.CustomViewCallback? = null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private var webPic: String? = null | 
					 | 
					 | 
					 | 
					    private val selectImageDir = registerForActivityResult(HandleFileContract()) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private val saveImage = registerForActivityResult(HandleFileContract()) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it.uri?.let { uri -> | 
					 | 
					 | 
					 | 
					        it.uri?.let { uri -> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ACache.get().put(imagePathKey, uri.toString()) | 
					 | 
					 | 
					 | 
					            ACache.get().put(imagePathKey, uri.toString()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            viewModel.saveImage(webPic, uri) | 
					 | 
					 | 
					 | 
					            viewModel.saveImage(it.value, uri) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -135,8 +135,18 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE || | 
					 | 
					 | 
					 | 
					            if (hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE || | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                hitTestResult.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE | 
					 | 
					 | 
					 | 
					                hitTestResult.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ) { | 
					 | 
					 | 
					 | 
					            ) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                hitTestResult.extra?.let { | 
					 | 
					 | 
					 | 
					                hitTestResult.extra?.let { webPic -> | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    saveImage(it) | 
					 | 
					 | 
					 | 
					                    selector( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        arrayListOf( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            SelectItem(getString(R.string.action_save), "save"), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            SelectItem(getString(R.string.select_folder), "selectFolder") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    ) { _, charSequence, i -> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        when (charSequence.value) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            "save" -> saveImage(webPic) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            "selectFolder" -> selectSaveFolder(null) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    return@setOnLongClickListener true | 
					 | 
					 | 
					 | 
					                    return@setOnLongClickListener true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -153,23 +163,23 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private fun saveImage(webPic: String) { | 
					 | 
					 | 
					 | 
					    private fun saveImage(webPic: String) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this.webPic = webPic | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val path = ACache.get().getAsString(imagePathKey) | 
					 | 
					 | 
					 | 
					        val path = ACache.get().getAsString(imagePathKey) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (path.isNullOrEmpty()) { | 
					 | 
					 | 
					 | 
					        if (path.isNullOrEmpty()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            selectSaveFolder() | 
					 | 
					 | 
					 | 
					            selectSaveFolder(webPic) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            viewModel.saveImage(webPic, Uri.parse(path)) | 
					 | 
					 | 
					 | 
					            viewModel.saveImage(webPic, Uri.parse(path)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private fun selectSaveFolder() { | 
					 | 
					 | 
					 | 
					    private fun selectSaveFolder(webPic: String?) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val default = arrayListOf<SelectItem<Int>>() | 
					 | 
					 | 
					 | 
					        val default = arrayListOf<SelectItem<Int>>() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val path = ACache.get().getAsString(imagePathKey) | 
					 | 
					 | 
					 | 
					        val path = ACache.get().getAsString(imagePathKey) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!path.isNullOrEmpty()) { | 
					 | 
					 | 
					 | 
					        if (!path.isNullOrEmpty()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            default.add(SelectItem(path, -1)) | 
					 | 
					 | 
					 | 
					            default.add(SelectItem(path, -1)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        saveImage.launch { | 
					 | 
					 | 
					 | 
					        selectImageDir.launch { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            otherActions = default | 
					 | 
					 | 
					 | 
					            otherActions = default | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            value = webPic | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |