๐Ÿ”— Redirect Bluesky links to your preferred client
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace Uri.parse() with toUri()

+27 -26
+2 -2
lemmyredirect/src/main/java/dev/zwander/lemmyredirect/util/LaunchStrategy.kt
··· 3 3 package dev.zwander.lemmyredirect.util 4 4 5 5 import android.content.Intent 6 - import android.net.Uri 7 6 import androidx.annotation.Keep 8 7 import androidx.annotation.StringRes 9 8 import dev.zwander.lemmyredirect.R 10 9 import dev.zwander.shared.LaunchIntentCreator 11 10 import dev.zwander.shared.LaunchStrategy 12 11 import dev.zwander.shared.LaunchStrategyRootGroup 12 + import androidx.core.net.toUri 13 13 14 14 /** 15 15 * This file contains the supported launch strategies. ··· 152 152 "https://github.com/aeharding/voyager", 153 153 LaunchIntentCreator.CustomIntentCreator { url -> 154 154 listOf( 155 - Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply { 155 + Intent(Intent.ACTION_VIEW, url.toUri()).apply { 156 156 addCategory(Intent.CATEGORY_BROWSABLE) 157 157 addCategory(Intent.CATEGORY_DEFAULT) 158 158
+3 -3
shared/src/main/java/dev/zwander/shared/LaunchIntentCreator.kt
··· 3 3 import android.content.ComponentName 4 4 import android.content.Context 5 5 import android.content.Intent 6 - import android.net.Uri 6 + import androidx.core.net.toUri 7 7 8 8 sealed interface LaunchIntentCreator { 9 9 fun Context.createIntents(url: String): List<Intent> ··· 55 55 ) : LaunchIntentCreator { 56 56 override fun Context.createIntents(url: String): List<Intent> { 57 57 return listOf( 58 - Intent(Intent.ACTION_VIEW, Uri.parse("$baseUrl$url")) 58 + Intent(Intent.ACTION_VIEW, "$baseUrl$url".toUri()) 59 59 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 60 60 ) 61 61 } ··· 80 80 81 81 `package` = packageName 82 82 component = cmp 83 - data = Uri.parse(url) 83 + data = url.toUri() 84 84 } 85 85 } 86 86 }
+5 -5
shared/src/main/java/dev/zwander/shared/RedirectActivity.kt
··· 1 1 package dev.zwander.shared 2 2 3 3 import android.content.Intent 4 - import android.net.Uri 5 4 import android.util.Log 6 5 import androidx.compose.foundation.layout.Box 7 6 import androidx.compose.foundation.layout.Spacer ··· 39 38 import kotlinx.coroutines.delay 40 39 import kotlinx.coroutines.withContext 41 40 import java.net.URLConnection 41 + import androidx.core.net.toUri 42 42 43 43 class RedirectActivity : BaseActivity(), CoroutineScope by MainScope() { 44 44 @OptIn(ExperimentalMaterial3Api::class) ··· 110 110 val lastHandledLinkIsTheSame = prefs.lastHandledLink.currentValue(this) == url 111 111 112 112 val skipUrl = url?.let { 113 - prefs.blocklistedDomains.currentValue(this).contains(Uri.parse(it).host) 113 + prefs.blocklistedDomains.currentValue(this).contains(it.toUri().host) 114 114 } == true 115 115 116 116 when { ··· 174 174 private suspend fun isUrlMedia(url: String): Boolean { 175 175 val parsedUrl = try { 176 176 Url(url) 177 - } catch (e: Exception) { 177 + } catch (_: Exception) { 178 178 null 179 179 } 180 180 ··· 195 195 returnedType == "video" || 196 196 returnedType == "image" || 197 197 returnedType == "audio" 198 - } catch (e: Exception) { 198 + } catch (_: Exception) { 199 199 false 200 200 } 201 201 } 202 202 203 203 private fun isSpecialUrl(url: String): Boolean { 204 - val parsedUrl = Uri.parse(url) 204 + val parsedUrl = url.toUri() 205 205 val path = parsedUrl.path 206 206 207 207 val specialStarters = arrayOf(
+6 -6
shared/src/main/java/dev/zwander/shared/components/FooterLayout.kt
··· 1 1 package dev.zwander.shared.components 2 2 3 3 import android.content.Intent 4 - import android.net.Uri 5 4 import android.os.Build 6 5 import androidx.annotation.DrawableRes 7 6 import androidx.annotation.StringRes ··· 17 16 import androidx.compose.material3.CardDefaults 18 17 import androidx.compose.material3.ExperimentalMaterial3Api 19 18 import androidx.compose.material3.Icon 20 - import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement 19 + import androidx.compose.material3.LocalMinimumInteractiveComponentSize 21 20 import androidx.compose.material3.MaterialTheme 22 21 import androidx.compose.material3.Text 23 22 import androidx.compose.material3.TextButton ··· 47 46 import kotlinx.coroutines.Dispatchers 48 47 import kotlinx.coroutines.launch 49 48 import tk.zwander.patreonsupportersretrieval.view.SupporterView 49 + import androidx.core.net.toUri 50 50 51 51 private data class FooterButton( 52 52 @StringRes val labelRes: Int, ··· 80 80 R.string.github, 81 81 R.drawable.github, 82 82 ) { 83 - context.openLinkNaturally(Uri.parse("https://github.com/zacharee/MastodonRedirect/")) 83 + context.openLinkNaturally("https://github.com/zacharee/MastodonRedirect/".toUri()) 84 84 }, 85 85 FooterButton( 86 86 R.string.patreon, 87 87 R.drawable.patreon, 88 88 ) { 89 - context.openLinkNaturally(Uri.parse("https://www.patreon.com/zacharywander")) 89 + context.openLinkNaturally("https://www.patreon.com/zacharywander".toUri()) 90 90 }, 91 91 FooterButton( 92 92 R.string.mastodon, 93 93 R.drawable.mastodon, 94 94 ) { 95 - context.openLinkNaturally(Uri.parse("https://androiddev.social/@wander1236")) 95 + context.openLinkNaturally("https://androiddev.social/@wander1236".toUri()) 96 96 }, 97 97 FooterButton( 98 98 R.string.supporters, ··· 113 113 } 114 114 115 115 CompositionLocalProvider( 116 - LocalMinimumInteractiveComponentEnforcement provides false, 116 + LocalMinimumInteractiveComponentSize provides 24.dp, 117 117 ) { 118 118 FlowRow( 119 119 modifier = modifier.padding(bottom = 8.dp),
+2 -2
shared/src/main/java/dev/zwander/shared/components/LinkVerifyLayout.kt
··· 1 1 package dev.zwander.shared.components 2 2 3 3 import android.content.Intent 4 - import android.net.Uri 5 4 import android.os.Build 6 5 import androidx.compose.animation.AnimatedVisibility 7 6 import androidx.compose.animation.Crossfade ··· 65 64 import kotlinx.coroutines.launch 66 65 import rikka.shizuku.ShizukuProvider 67 66 import kotlin.coroutines.CoroutineContext 67 + import androidx.core.net.toUri 68 68 69 69 @Preview(showSystemUi = true) 70 70 @Composable ··· 299 299 TextButton( 300 300 onClick = { 301 301 val launchIntent = 302 - Intent(Intent.ACTION_VIEW, Uri.parse("https://shizuku.rikka.app")) 302 + Intent(Intent.ACTION_VIEW, "https://shizuku.rikka.app".toUri()) 303 303 context.startActivity(launchIntent) 304 304 showingShizukuInstallDialog = false 305 305 }
+3 -3
shared/src/main/java/dev/zwander/shared/util/BaseLaunchStrategyUtils.kt
··· 5 5 import android.content.Intent 6 6 import android.content.pm.PackageManager 7 7 import android.content.pm.ResolveInfo 8 - import android.net.Uri 9 8 import androidx.compose.runtime.Composable 10 9 import androidx.compose.runtime.remember 11 10 import androidx.compose.ui.platform.LocalContext ··· 14 13 import dev.zwander.shared.LaunchStrategy 15 14 import dev.zwander.shared.LaunchStrategyRootGroup 16 15 import kotlin.reflect.KClass 16 + import androidx.core.net.toUri 17 17 18 18 abstract class BaseLaunchStrategyUtils( 19 19 applicationId: String, ··· 104 104 scheme: String = "https", 105 105 newTask: Boolean = true, 106 106 ): Intent { 107 - val originalUri = Uri.parse(url) 108 - val newUri = Uri.parse(url.replace("${originalUri.scheme}://", "${scheme}://")) 107 + val originalUri = url.toUri() 108 + val newUri = url.replace("${originalUri.scheme}://", "${scheme}://").toUri() 109 109 110 110 return Intent(Intent.ACTION_VIEW, newUri).apply { 111 111 addCategory(Intent.CATEGORY_DEFAULT)
+2 -1
shared/src/main/java/dev/zwander/shared/util/LinkUtils.kt
··· 4 4 import android.content.Context 5 5 import android.content.Intent 6 6 import android.net.Uri 7 + import androidx.core.net.toUri 7 8 8 9 fun Context.openLinkInBrowser(uri: Uri?) { 9 10 val launchIntent = createBaseLaunchIntent(uri) 10 - launchIntent.selector = Intent(Intent.ACTION_VIEW, Uri.parse("https://")) 11 + launchIntent.selector = Intent(Intent.ACTION_VIEW, "https://".toUri()) 11 12 .addCategory(Intent.CATEGORY_BROWSABLE) 12 13 13 14 try {
+4 -4
shared/src/main/java/dev/zwander/shared/util/LinkVerifyActions.kt
··· 5 5 import android.content.ComponentName 6 6 import android.content.Context 7 7 import android.content.Intent 8 - import android.net.Uri 9 8 import android.provider.Settings 10 9 import android.util.Log 11 10 import dev.zwander.shared.RedirectActivity ··· 13 12 import kotlinx.coroutines.CoroutineScope 14 13 import kotlinx.coroutines.Dispatchers 15 14 import kotlinx.coroutines.launch 15 + import androidx.core.net.toUri 16 16 17 17 object LinkVerifyActions { 18 18 @SuppressLint("InlinedApi") ··· 21 21 val pDirect = "android.settings.APPLICATION_DETAILS_SETTINGS_OPEN_BY_DEFAULT_PAGE" 22 22 val appDetails = Settings.ACTION_APPLICATION_DETAILS_SETTINGS 23 23 24 - val intent = Intent(Intent.ACTION_VIEW, Uri.parse("package:$packageName")) 24 + val intent = Intent(Intent.ACTION_VIEW, "package:$packageName".toUri()) 25 25 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 26 26 27 27 arrayOf(qDirect, pDirect, appDetails).forEach { action -> ··· 46 46 ) { 47 47 when (linkSheetStatus) { 48 48 LinkSheetStatus.NOT_INSTALLED -> { 49 - openLinkNaturally(Uri.parse("https://github.com/1fexd/LinkSheet")) 49 + openLinkNaturally("https://github.com/1fexd/LinkSheet".toUri()) 50 50 } 51 51 LinkSheetStatus.INSTALLED_NO_INTERCONNECT -> { 52 52 linkSheet?.packageName?.let { pkg -> ··· 83 83 ) 84 84 85 85 refresh() 86 - } catch (e: Exception) { 86 + } catch (_: Exception) { 87 87 service.selectDomains( 88 88 packageName = packageName, 89 89 domains = missingDomains,