| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -18,7 +18,7 @@ import io.legado.app.help.storage.Restore | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.help.storage.WebDavHelp | 
					 | 
					 | 
					 | 
					import io.legado.app.help.storage.WebDavHelp | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.ui.filepicker.FilePicker | 
					 | 
					 | 
					 | 
					import io.legado.app.ui.filepicker.FilePicker | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.getPrefString | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.getPrefString | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.isContentPath | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.isContentScheme | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.longToast | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.longToast | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.toast | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.toast | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import kotlinx.coroutines.Dispatchers.Main | 
					 | 
					 | 
					 | 
					import kotlinx.coroutines.Dispatchers.Main | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -35,7 +35,7 @@ object BackupRestoreUi { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (backupPath.isNullOrEmpty()) { | 
					 | 
					 | 
					 | 
					        if (backupPath.isNullOrEmpty()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            selectBackupFolder(fragment, backupSelectRequestCode) | 
					 | 
					 | 
					 | 
					            selectBackupFolder(fragment, backupSelectRequestCode) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (backupPath.isContentPath()) { | 
					 | 
					 | 
					 | 
					            if (backupPath.isContentScheme()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                val uri = Uri.parse(backupPath) | 
					 | 
					 | 
					 | 
					                val uri = Uri.parse(backupPath) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                val doc = DocumentFile.fromTreeUri(fragment.requireContext(), uri) | 
					 | 
					 | 
					 | 
					                val doc = DocumentFile.fromTreeUri(fragment.requireContext(), uri) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (doc?.canWrite() == true) { | 
					 | 
					 | 
					 | 
					                if (doc?.canWrite() == true) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -82,7 +82,7 @@ object BackupRestoreUi { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            fragment.longToast("WebDavError:${it.localizedMessage}\n将从本地备份恢复。") | 
					 | 
					 | 
					 | 
					            fragment.longToast("WebDavError:${it.localizedMessage}\n将从本地备份恢复。") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            val backupPath = fragment.getPrefString(PreferKey.backupPath) | 
					 | 
					 | 
					 | 
					            val backupPath = fragment.getPrefString(PreferKey.backupPath) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (backupPath?.isNotEmpty() == true) { | 
					 | 
					 | 
					 | 
					            if (backupPath?.isNotEmpty() == true) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (backupPath.isContentPath()) { | 
					 | 
					 | 
					 | 
					                if (backupPath.isContentScheme()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val uri = Uri.parse(backupPath) | 
					 | 
					 | 
					 | 
					                    val uri = Uri.parse(backupPath) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val doc = DocumentFile.fromTreeUri(fragment.requireContext(), uri) | 
					 | 
					 | 
					 | 
					                    val doc = DocumentFile.fromTreeUri(fragment.requireContext(), uri) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (doc?.canWrite() == true) { | 
					 | 
					 | 
					 | 
					                    if (doc?.canWrite() == true) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -125,7 +125,7 @@ object BackupRestoreUi { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        when (requestCode) { | 
					 | 
					 | 
					 | 
					        when (requestCode) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            backupSelectRequestCode -> if (resultCode == RESULT_OK) { | 
					 | 
					 | 
					 | 
					            backupSelectRequestCode -> if (resultCode == RESULT_OK) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (uri.isContentPath()) { | 
					 | 
					 | 
					 | 
					                    if (uri.isContentScheme()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            uri, | 
					 | 
					 | 
					 | 
					                            uri, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -151,7 +151,7 @@ object BackupRestoreUi { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            restoreSelectRequestCode -> if (resultCode == RESULT_OK) { | 
					 | 
					 | 
					 | 
					            restoreSelectRequestCode -> if (resultCode == RESULT_OK) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (uri.isContentPath()) { | 
					 | 
					 | 
					 | 
					                    if (uri.isContentScheme()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            uri, | 
					 | 
					 | 
					 | 
					                            uri, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -173,7 +173,7 @@ object BackupRestoreUi { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            selectFolderRequestCode -> if (resultCode == RESULT_OK) { | 
					 | 
					 | 
					 | 
					            selectFolderRequestCode -> if (resultCode == RESULT_OK) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
					 | 
					 | 
					 | 
					                data?.data?.let { uri -> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (uri.isContentPath()) { | 
					 | 
					 | 
					 | 
					                    if (uri.isContentScheme()) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
					 | 
					 | 
					 | 
					                        App.INSTANCE.contentResolver.takePersistableUriPermission( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            uri, | 
					 | 
					 | 
					 | 
					                            uri, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
					 | 
					 | 
					 | 
					                            Intent.FLAG_GRANT_READ_URI_PERMISSION | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |