mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	Fix link loading repos
This commit is contained in:
		
							parent
							
								
									8162e48b92
								
							
						
					
					
						commit
						bb2385fef3
					
				
					 3 changed files with 40 additions and 17 deletions
				
			
		|  | @ -83,6 +83,21 @@ | |||
|                 <category android:name="android.intent.category.BROWSABLE" /> | ||||
| 
 | ||||
|                 <data android:scheme="cloudstreamapp" /> | ||||
|             </intent-filter> | ||||
|             <intent-filter> | ||||
|                 <action android:name="android.intent.action.VIEW" /> | ||||
| 
 | ||||
|                 <category android:name="android.intent.category.DEFAULT" /> | ||||
|                 <category android:name="android.intent.category.BROWSABLE" /> | ||||
| 
 | ||||
|                 <data android:scheme="cloudstreamrepo" /> | ||||
|             </intent-filter> | ||||
|             <intent-filter> | ||||
|                 <action android:name="android.intent.action.VIEW" /> | ||||
| 
 | ||||
|                 <category android:name="android.intent.category.DEFAULT" /> | ||||
|                 <category android:name="android.intent.category.BROWSABLE" /> | ||||
| 
 | ||||
|                 <data | ||||
|                     android:host="cs.repo" | ||||
|                     android:pathPrefix="/" | ||||
|  |  | |||
|  | @ -84,6 +84,7 @@ import kotlin.reflect.KClass | |||
| import com.lagradost.cloudstream3.plugins.PluginManager | ||||
| import com.lagradost.cloudstream3.plugins.RepositoryManager | ||||
| import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIES | ||||
| import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringRepo | ||||
| import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData | ||||
| import com.lagradost.cloudstream3.utils.Coroutines.main | ||||
| 
 | ||||
|  | @ -328,6 +329,25 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | |||
|         super.onNewIntent(intent) | ||||
|     } | ||||
| 
 | ||||
|     private fun loadRepo(url: String) { | ||||
|         ioSafe { | ||||
|             val repo = RepositoryManager.parseRepository(url) ?: return@ioSafe | ||||
|             RepositoryManager.addRepository( | ||||
|                 RepositoryData( | ||||
|                     repo.name, | ||||
|                     url | ||||
|                 ) | ||||
|             ) | ||||
|             main { | ||||
|                 showToast( | ||||
|                     this@MainActivity, | ||||
|                     getString(R.string.player_loaded_subtitles, repo.name), | ||||
|                     Toast.LENGTH_LONG | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private fun handleAppIntent(intent: Intent?) { | ||||
|         if (intent == null) return | ||||
|         val str = intent.dataString | ||||
|  | @ -336,23 +356,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | |||
|             if (str.startsWith("https://cs.repo")) { | ||||
|                 val realUrl = "https://" + str.substringAfter("?") | ||||
|                 println("Repository url: $realUrl") | ||||
|                 val activity = this | ||||
|                 ioSafe { | ||||
|                     val repo = RepositoryManager.parseRepository(realUrl) ?: return@ioSafe | ||||
|                     RepositoryManager.addRepository( | ||||
|                         RepositoryData( | ||||
|                             repo.name, | ||||
|                             realUrl | ||||
|                         ) | ||||
|                     ) | ||||
|                     main { | ||||
|                         showToast( | ||||
|                             activity, | ||||
|                             getString(R.string.player_loaded_subtitles, repo.name), | ||||
|                             Toast.LENGTH_LONG | ||||
|                         ) | ||||
|                     } | ||||
|                 } | ||||
|                 loadRepo(realUrl) | ||||
|             } else if (str.contains(appString)) { | ||||
|                 for (api in OAuth2Apis) { | ||||
|                     if (str.contains("/${api.redirectUrl}")) { | ||||
|  | @ -382,6 +386,9 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | |||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } else if (str.contains(appStringRepo)) { | ||||
|                 val url = str.replaceFirst(appStringRepo, "https") | ||||
|                 loadRepo(url) | ||||
|             } else { | ||||
|                 if (str.startsWith(DOWNLOAD_NAVIGATE_TO)) { | ||||
|                     this.navigate(R.id.navigation_downloads) | ||||
|  |  | |||
|  | @ -42,6 +42,7 @@ abstract class AccountManager(private val defIndex: Int) : AuthAPI { | |||
|             ) | ||||
| 
 | ||||
|         const val appString = "cloudstreamapp" | ||||
|         const val appStringRepo = "cloudstreamrepo" | ||||
| 
 | ||||
|         val unixTime: Long | ||||
|             get() = System.currentTimeMillis() / 1000L | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue