diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index 5eee9dac2..01cf4a378 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -142,8 +142,7 @@ class MainActivity : AppCompatActivity() { override fun onStart() { super.onStart() - val action: String? = intent?.action - val data: Uri? = z + val data: Uri? = intent?.data Log.d(TAG, "dafaq" + data.toString()) if (data != null) { @@ -155,12 +154,15 @@ class MainActivity : AppCompatActivity() { data.path!!.contains("/c/") || data.path!!.contains("/user/") ) { + Log.i(TAG, "URI Type: Channel") var channel = data.path channel = channel!!.replace("/c/", "") channel = channel.replace("/user/", "") + Log.i(TAG, channel) val bundle = bundleOf("channel_id" to channel) navController.navigate(R.id.channel, bundle) } else if (data.path!!.contains("/playlist")) { + Log.i(TAG, "URI Type: Playlist") var playlist = data.query!! if (playlist.contains("&")) { var playlists = playlist.split("&") @@ -178,6 +180,7 @@ class MainActivity : AppCompatActivity() { data.path!!.contains("/embed/") || data.path!!.contains("/v/") ) { + Log.i(TAG, "URI Type: Video") val watch = data.path!! .replace("/shorts/", "") .replace("/v/", "") diff --git a/app/src/main/java/com/github/libretube/RouterActivity.kt b/app/src/main/java/com/github/libretube/RouterActivity.kt index 7f6768ecb..7f7d541b5 100644 --- a/app/src/main/java/com/github/libretube/RouterActivity.kt +++ b/app/src/main/java/com/github/libretube/RouterActivity.kt @@ -1,11 +1,14 @@ package com.github.libretube import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri import android.os.Bundle import android.util.Log import androidx.appcompat.app.AppCompatActivity class RouterActivity : AppCompatActivity() { + val TAG = "RouterActivity" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) when (intent?.action) { @@ -19,8 +22,12 @@ class RouterActivity : AppCompatActivity() { private fun handleSendText(intent: Intent) { intent.getStringExtra(Intent.EXTRA_TEXT)?.let { - Log.i(it,it) + Log.i(TAG, it) + val pm: PackageManager = this.packageManager + val intent = pm.getLaunchIntentForPackage(this.packageName) + intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK + intent?.data = Uri.parse(it) + this.startActivity(intent) } } - -} \ No newline at end of file +}