mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
comments
This commit is contained in:
parent
c1ac7aa816
commit
a5bfa2c1bb
@ -143,8 +143,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val intentData: Uri? = intent?.data
|
val intentData: Uri? = intent?.data
|
||||||
|
// check whether an URI got submitted over the intent data
|
||||||
if (intentData != null && intentData.host != null && intentData.path != null) {
|
if (intentData != null && intentData.host != null && intentData.path != null) {
|
||||||
Log.d("intentData", "${intentData.host} ${intentData.path} ")
|
Log.d("intentData", "${intentData.host} ${intentData.path} ")
|
||||||
|
// load the URI of the submitted link (e.g. video)
|
||||||
loadIntentData(intentData)
|
loadIntentData(intentData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,20 @@ class RouterActivity : AppCompatActivity() {
|
|||||||
val TAG = "RouterActivity"
|
val TAG = "RouterActivity"
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
when (intent?.action) {
|
// Check if Intent Action is ACTION_SEND
|
||||||
Intent.ACTION_SEND -> {
|
if (intent?.action == Intent.ACTION_SEND) {
|
||||||
if (intent.type == "text/plain" && checkHost(intent)) {
|
if (intent.type == "text/plain" && checkHost(intent)) {
|
||||||
handleSendText(intent)
|
// start the main activity using the given URI as data if the host is known
|
||||||
} else {
|
handleSendText(intent)
|
||||||
// start app as normal if wrong intent type
|
} else {
|
||||||
restartMainActivity(this)
|
// start app as normal if wrong intent type
|
||||||
}
|
restartMainActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHost(intent: Intent): Boolean {
|
private fun checkHost(intent: Intent): Boolean {
|
||||||
|
// check whether the host is known, current solution to replace the broken intent filter
|
||||||
val hostsList = resources.getStringArray(R.array.shareHostsList)
|
val hostsList = resources.getStringArray(R.array.shareHostsList)
|
||||||
val intentDataUri: Uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT))
|
val intentDataUri: Uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT))
|
||||||
val intentDataHost = intentDataUri.host
|
val intentDataHost = intentDataUri.host
|
||||||
@ -35,6 +36,7 @@ class RouterActivity : AppCompatActivity() {
|
|||||||
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
|
intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
|
||||||
Log.i(TAG, it)
|
Log.i(TAG, it)
|
||||||
val pm: PackageManager = this.packageManager
|
val pm: PackageManager = this.packageManager
|
||||||
|
// startIntent(this, MainActivity::class.java doesn't work for the activity aliases needed for the logo switch option
|
||||||
val intent = pm.getLaunchIntentForPackage(this.packageName)
|
val intent = pm.getLaunchIntentForPackage(this.packageName)
|
||||||
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
intent?.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||||
intent?.data = Uri.parse(it)
|
intent?.data = Uri.parse(it)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user