Merge 183fb7e072
into b2547c5eef
This commit is contained in:
commit
0dcfa71c51
|
@ -56,44 +56,45 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize"
|
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout|smallestScreenSize"
|
||||||
|
android:launchMode="singleTask"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<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="text/plain" />
|
<data android:mimeType="text/plain" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<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="image/*" />
|
<data android:mimeType="image/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<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="video/*" />
|
<data android:mimeType="video/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
<data android:mimeType="image/*" />
|
<data android:mimeType="image/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
<data android:mimeType="video/*" />
|
<data android:mimeType="video/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter android:label="@string/action_compose">
|
||||||
<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" />
|
||||||
|
@ -101,10 +102,31 @@
|
||||||
<data android:mimeType="audio/*" />
|
<data android:mimeType="audio/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="dev.zwander.mastodonredirect.intent.action.OPEN_FEDI_LINK" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.service.chooser.chooser_target_service"
|
android:name="android.service.chooser.chooser_target_service"
|
||||||
android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
|
android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".components.view.ViewLinkActivity"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/NullTheme">
|
||||||
|
|
||||||
|
<intent-filter android:label="@string/open_link">
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".components.compose.ComposeActivity"
|
android:name=".components.compose.ComposeActivity"
|
||||||
|
|
|
@ -527,9 +527,17 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
if (redirectUrl != null) {
|
if (redirectUrl != null) {
|
||||||
viewUrl(redirectUrl, PostLookupFallbackBehavior.DISPLAY_ERROR)
|
viewUrl(redirectUrl, PostLookupFallbackBehavior.DISPLAY_ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMastodonRedirectIntent(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onNewIntent(intent: Intent?) {
|
||||||
|
super.onNewIntent(intent)
|
||||||
|
|
||||||
|
handleMastodonRedirectIntent(intent)
|
||||||
|
}
|
||||||
|
|
||||||
private fun forwardToComposeActivity(intent: Intent) {
|
private fun forwardToComposeActivity(intent: Intent) {
|
||||||
val composeOptions = IntentCompat.getParcelableExtra(
|
val composeOptions = IntentCompat.getParcelableExtra(
|
||||||
intent,
|
intent,
|
||||||
|
@ -1219,6 +1227,14 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
|
|
||||||
override fun androidInjector() = androidInjector
|
override fun androidInjector() = androidInjector
|
||||||
|
|
||||||
|
private fun handleMastodonRedirectIntent(intent: Intent?) {
|
||||||
|
if (intent?.action == "dev.zwander.mastodonredirect.intent.action.OPEN_FEDI_LINK") {
|
||||||
|
intent.dataString?.let { url ->
|
||||||
|
viewUrl(url, PostLookupFallbackBehavior.OPEN_IN_BROWSER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val OPEN_WITH_EXPLODE_ANIMATION = "explode"
|
const val OPEN_WITH_EXPLODE_ANIMATION = "explode"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.keylesspalace.tusky.components.view
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.keylesspalace.tusky.BaseActivity
|
||||||
|
import com.keylesspalace.tusky.MainActivity
|
||||||
|
import com.keylesspalace.tusky.di.Injectable
|
||||||
|
|
||||||
|
class ViewLinkActivity : BaseActivity(), Injectable {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
if (intent?.action == Intent.ACTION_SEND) {
|
||||||
|
val link = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||||
|
|
||||||
|
val launchIntent = Intent(this, MainActivity::class.java)
|
||||||
|
launchIntent.action = "dev.zwander.mastodonredirect.intent.action.OPEN_FEDI_LINK"
|
||||||
|
launchIntent.data = link?.let { Uri.parse(it) }
|
||||||
|
|
||||||
|
startActivity(launchIntent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ import com.keylesspalace.tusky.components.report.ReportActivity
|
||||||
import com.keylesspalace.tusky.components.scheduled.ScheduledStatusActivity
|
import com.keylesspalace.tusky.components.scheduled.ScheduledStatusActivity
|
||||||
import com.keylesspalace.tusky.components.search.SearchActivity
|
import com.keylesspalace.tusky.components.search.SearchActivity
|
||||||
import com.keylesspalace.tusky.components.trending.TrendingActivity
|
import com.keylesspalace.tusky.components.trending.TrendingActivity
|
||||||
|
import com.keylesspalace.tusky.components.view.ViewLinkActivity
|
||||||
import com.keylesspalace.tusky.components.viewthread.ViewThreadActivity
|
import com.keylesspalace.tusky.components.viewthread.ViewThreadActivity
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
@ -132,4 +133,7 @@ abstract class ActivitiesModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun contributesEditFilterActivity(): EditFilterActivity
|
abstract fun contributesEditFilterActivity(): EditFilterActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesViewLinkActivity(): ViewLinkActivity
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,6 +312,10 @@ fun Context.openLink(url: String) {
|
||||||
*/
|
*/
|
||||||
private fun openLinkInBrowser(uri: Uri?, context: Context) {
|
private fun openLinkInBrowser(uri: Uri?, context: Context) {
|
||||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||||
|
|
||||||
|
// Makes sure the Intent opens in the browser instead of something like Mastodon Redirect.
|
||||||
|
intent.selector = Intent(Intent.ACTION_VIEW, Uri.parse("https://"))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
|
|
@ -851,4 +851,6 @@
|
||||||
<string name="list_reply_policy_list">Members of the list</string>
|
<string name="list_reply_policy_list">Members of the list</string>
|
||||||
<string name="list_reply_policy_followed">Any followed user</string>
|
<string name="list_reply_policy_followed">Any followed user</string>
|
||||||
<string name="list_reply_policy_label">Show replies to</string>
|
<string name="list_reply_policy_label">Show replies to</string>
|
||||||
|
|
||||||
|
<string name="open_link">Open Link</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -185,4 +185,17 @@
|
||||||
<item name="android:layout_marginLeft">20dp</item>
|
<item name="android:layout_marginLeft">20dp</item>
|
||||||
<item name="android:layout_marginRight">20dp</item>
|
<item name="android:layout_marginRight">20dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="NullTheme" parent="Theme.Material3.DynamicColors.DayNight">
|
||||||
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
<item name="android:backgroundDimEnabled">false</item>
|
||||||
|
<item name="android:windowEnterAnimation">@null</item>
|
||||||
|
<item name="android:windowExitAnimation">@null</item>
|
||||||
|
<item name="android:windowNoDisplay">true</item>
|
||||||
|
<item name="android:windowActionBar">false</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue