This commit is contained in:
Bnyro 2022-05-29 15:57:01 +02:00
parent 06688c6faf
commit cd47970eac
3 changed files with 106 additions and 110 deletions

View File

@ -169,13 +169,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/*" /> <data android:mimeType="text/plain" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="message/*" />
<data android:mimeType="multipart/*" />
<data android:mimeType="text/*" />
<data android:mimeType="video/*" />
</intent-filter> </intent-filter>
<!-- youtube --> <!-- youtube -->
<intent-filter> <intent-filter>

View File

@ -1,6 +1,7 @@
package com.github.libretube package com.github.libretube
import android.app.Activity import android.app.Activity
import android.app.ProgressDialog.show
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
@ -33,6 +34,7 @@ import androidx.preference.PreferenceManager
import com.github.libretube.util.CronetHelper import com.github.libretube.util.CronetHelper
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColors
import kotlinx.coroutines.NonDisposableHandle.parent
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
val TAG = "MainActivity" val TAG = "MainActivity"
@ -142,13 +144,14 @@ class MainActivity : AppCompatActivity() {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
val data: Uri? = intent?.data val intentData: Uri? = intent?.data
Log.d(TAG, "dafaq" + data.toString()) if (intentData != null && intentData.host != null && intentData.path != null) {
Log.d("intentData", "${intentData.host} ${intentData.path} ")
loadIntentData(intentData)
}
}
if (data != null) { private fun loadIntentData(data: Uri) {
Log.d("dafaq", data.host + " ${data.path} ")
if (data.host != null) {
if (data.path != null) {
// channel // channel
if (data.path!!.contains("/channel/") || if (data.path!!.contains("/channel/") ||
data.path!!.contains("/c/") || data.path!!.contains("/c/") ||
@ -158,7 +161,6 @@ class MainActivity : AppCompatActivity() {
var channel = data.path var channel = data.path
channel = channel!!.replace("/c/", "") channel = channel!!.replace("/c/", "")
channel = channel.replace("/user/", "") channel = channel.replace("/user/", "")
Log.i(TAG, channel)
val bundle = bundleOf("channel_id" to channel) val bundle = bundleOf("channel_id" to channel)
navController.navigate(R.id.channel, bundle) navController.navigate(R.id.channel, bundle)
} else if (data.path!!.contains("/playlist")) { } else if (data.path!!.contains("/playlist")) {
@ -246,9 +248,6 @@ class MainActivity : AppCompatActivity() {
}, 100) }, 100)
} }
} }
}
}
}
override fun onBackPressed() { override fun onBackPressed() {
try { try {

View File

@ -13,8 +13,11 @@ class RouterActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
when (intent?.action) { when (intent?.action) {
Intent.ACTION_SEND -> { Intent.ACTION_SEND -> {
if ("text/plain" == intent.type) { if (intent.type == "text/plain") {
handleSendText(intent) // Handle text being sent handleSendText(intent)
} else {
// start app as normal if wrong intent type
restartMainActivity(this)
} }
} }
} }