Support Open as default for all public Piped instances

This commit is contained in:
Bnyro 2023-01-08 16:19:44 +01:00
parent 1da89eed43
commit fd4cd9fa26
3 changed files with 29 additions and 150 deletions

View File

@ -267,12 +267,14 @@
android:name=".ui.activities.RouterActivity"
android:exported="true"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<!-- youtube -->
<!-- YouTube -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@ -289,7 +291,6 @@
<data android:pathPrefix="/v/" />
<data android:pathPrefix="/embed/" />
<data android:pathPrefix="/watch" />
<!--<data android:pathPrefix="/attribution_link" />-->
<data android:pathPrefix="/shorts/" />
<!-- channel prefix -->
<data android:pathPrefix="/channel/" />
@ -298,6 +299,8 @@
<!-- playlist prefix -->
<data android:pathPrefix="/playlist" />
</intent-filter>
<!-- Support being detected as media player -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
@ -311,46 +314,7 @@
<data android:host="youtu.be" />
<data android:pathPrefix="/" />
</intent-filter>
<!-- Invidious filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="tubus.eduvid.org" />
<data android:host="invidio.us" />
<data android:host="dev.invidio.us" />
<data android:host="www.invidio.us" />
<data android:host="redirect.invidious.io" />
<data android:host="invidious.snopyta.org" />
<data android:host="yewtu.be" />
<data android:host="tube.connect.cafe" />
<data android:host="invidious.kavin.rocks" />
<data android:host="invidious-us.kavin.rocks" />
<data android:host="invidious.site" />
<data android:host="vid.mint.lgbt" />
<data android:host="invidiou.site" />
<data android:host="invidious.fdn.fr" />
<data android:host="invidious.048596.xyz" />
<data android:host="invidious.zee.li" />
<data android:host="vid.puffyan.us" />
<data android:host="ytprivate.com" />
<data android:host="invidious.namazso.eu" />
<data android:host="invidious.silkky.cloud" />
<data android:host="invidious.exonip.de" />
<data android:host="inv.riverside.rocks" />
<data android:host="invidious.blamefran.net" />
<data android:host="invidious.moomoo.me" />
<data android:host="ytb.trom.tf" />
<data android:host="yt.cyberhost.uk" />
<data android:host="y.com.cm" />
<data android:pathPrefix="/" />
</intent-filter>
<!-- Piped filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@ -362,14 +326,27 @@
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="piped.video" />
<data android:host="piped.tokhmi.xyz" />
<data android:host="piped.kavin.rocks" />
<data android:host="piped.silkky.cloud" />
<data android:host="piped.silkky.cloud" />
<data android:host="piped.mint.lgbt" />
<data android:host="il.ax" />
<data android:pathPrefix="/" />
<data android:host="piped.video" />
<data android:host="piped.kavin.rocks" />
<data android:host="piped.syncpundit.io" />
<data android:host="piped.mha.fi" />
<data android:host="watch.whatever.social" />
<data android:host="piped.garudalinux.org" />
<data android:host="piped.aeong.one" />
<data android:host="watch.leptons.xyz" />
<data android:host="yt.jae.fi" />
<data android:host="il.ax" />
<data android:host="piped.esmailelbob.xyz" />
<data android:host="piped.adminforge.de" />
<data android:host="piped.qdi.fi" />
<data android:host="piped.hostux.net" />
<data android:host="pd.vern.cc" />
<data android:host="piped.chauvet.pro" />
<data android:host="piped.privacydev.net" />
<data android:host="piped.palveluntarjoaja.eu" />
<data android:host="piped.smnz.de" />
</intent-filter>
</activity>

View File

@ -5,7 +5,6 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.util.Log
import com.github.libretube.R
import com.github.libretube.constants.IntentData
import com.github.libretube.extensions.TAG
import com.github.libretube.ui.base.BaseActivity
@ -15,28 +14,18 @@ import kotlin.time.Duration
class RouterActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (intent.getStringExtra(Intent.EXTRA_TEXT) != null && checkHost(intent)) {
// start the main activity using the given URI as data if the host is known
val uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT)!!)
handleSendText(uri)
if (intent.getStringExtra(Intent.EXTRA_TEXT) != null) {
// start processing the given text
handleSendText(Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT)!!))
} else if (intent.data != null) {
val uri = intent.data
handleSendText(uri!!)
} else {
// start app as normal if URI not in host list
// start app as normal if unknown action, shouldn't be reachable
NavigationHelper.restartMainActivity(this)
}
}
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 intentDataUri: Uri = Uri.parse(intent.getStringExtra(Intent.EXTRA_TEXT))
val intentDataHost = intentDataUri.host
Log.d(TAG(), "$intentDataHost")
return hostsList.contains(intentDataHost)
}
/**
* Resolve the uri and return a bundle with the arguments
*/

View File

@ -25,93 +25,6 @@
<item>https://piped-api.privacy.com.de/</item>
</string-array>
<string-array name="shareHostsList">
<item>youtube.com"</item>
<item>m.youtube.com"</item>
<item>www.youtube.com"</item>
<item>music.youtube.com"</item>
<item>youtu.be"</item>
<item>tubus.eduvid.org"</item>
<item>invidio.us"</item>
<item>dev.invidio.us"</item>
<item>www.invidio.us"</item>
<item>redirect.invidious.io"</item>
<item>invidious.snopyta.org"</item>
<item>yewtu.be"</item>
<item>tube.connect.cafe"</item>
<item>invidious.kavin.rocks"</item>
<item>invidious-us.kavin.rocks"</item>
<item>invidious.site"</item>
<item>vid.mint.lgbt"</item>
<item>invidiou.site"</item>
<item>invidious.fdn.fr"</item>
<item>invidious.048596.xyz"</item>
<item>invidious.zee.li"</item>
<item>vid.puffyan.us"</item>
<item>ytprivate.com"</item>
<item>invidious.namazso.eu"</item>
<item>invidious.silkky.cloud"</item>
<item>invidious.exonip.de"</item>
<item>inv.riverside.rocks"</item>
<item>invidious.blamefran.net"</item>
<item>invidious.moomoo.me"</item>
<item>ytb.trom.tf"</item>
<item>yt.cyberhost.uk"</item>
<item>y.com.cm"</item>
<item>piped.video"</item>
<item>piped.tokhmi.xyz"</item>
<item>piped.kavin.rocks"</item>
<item>piped.silkky.cloud"</item>
<item>piped.silkky.cloud"</item>
<item>piped.mint.lgbt"</item>
<item>il.ax"</item>
</string-array>
<string-array name="languages">
<item>@string/systemLanguage</item>
<item>العربية</item>
<item>Azərbaycan dili</item>
<item>Euskara</item>
<item>বাংলা</item>
<item>Català</item>
<item>简体中文</item>
<item>繁體中文</item>
<item>čeština</item>
<item>Dansk</item>
<item>English</item>
<item>Wikang Filipino</item>
<item>Suomi</item>
<item>Français</item>
<item>Deutsch</item>
<item>Ελληνικά</item>
<item>ગુજરાતી</item>
<item>עברית</item>
<item>हिन्दी</item>
<item>Magyar</item>
<item>Bahasa Indonesia</item>
<item>Italiano</item>
<item>日本語</item>
<item>조선말</item>
<item>latviešu</item>
<item>മലയാളം</item>
<item>मराठी</item>
<item>Norsk</item>
<item>فارسی</item>
<item>ଓଡ଼ିଆ</item>
<item>Polski</item>
<item>Português</item>
<item>Português (BR)</item>
<item>Română</item>
<item>Русский</item>
<item>Slovenčina</item>
<item>سۆرانی</item>
<item>Español</item>
<item>ภาษาไทย</item>
<item>Türkçe</item>
<item>Türkmençe</item>
<item>Українська</item>
</string-array>
<string-array name="languagesValue">
<item>sys</item>
<item>ar</item>