enhance bad-domain detection
This commit is contained in:
parent
ee35a9768f
commit
b15a5c7614
|
@ -33,8 +33,9 @@ import com.keylesspalace.tusky.di.Injectable
|
||||||
import com.keylesspalace.tusky.entity.AccessToken
|
import com.keylesspalace.tusky.entity.AccessToken
|
||||||
import com.keylesspalace.tusky.entity.AppCredentials
|
import com.keylesspalace.tusky.entity.AppCredentials
|
||||||
import com.keylesspalace.tusky.network.MastodonApi
|
import com.keylesspalace.tusky.network.MastodonApi
|
||||||
import com.keylesspalace.tusky.util.RickRoll
|
|
||||||
import com.keylesspalace.tusky.util.ThemeUtils
|
import com.keylesspalace.tusky.util.ThemeUtils
|
||||||
|
import com.keylesspalace.tusky.util.rickRoll
|
||||||
|
import com.keylesspalace.tusky.util.shouldRickRoll
|
||||||
import kotlinx.android.synthetic.main.activity_login.*
|
import kotlinx.android.synthetic.main.activity_login.*
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
|
@ -139,8 +140,8 @@ class LoginActivity : BaseActivity(), Injectable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RickRoll.shouldRickRoll(this, domain)) {
|
if (shouldRickRoll(this, domain)) {
|
||||||
RickRoll.rickRoll(this)
|
rickRoll(this)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,16 @@ import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.keylesspalace.tusky.R
|
import com.keylesspalace.tusky.R
|
||||||
|
|
||||||
object RickRoll {
|
fun shouldRickRoll(context: Context, domain: String) =
|
||||||
fun shouldRickRoll(context: Context, domain: String) =
|
context.resources.getStringArray(R.array.rick_roll_domains).any { candidate ->
|
||||||
context.resources.getStringArray(R.array.rick_roll_domains).contains(domain)
|
domain.equals(candidate, true) || domain.endsWith(".$candidate", true)
|
||||||
|
|
||||||
fun rickRoll(context: Context) {
|
|
||||||
val uri = Uri.parse(context.getString(R.string.rick_roll_url))
|
|
||||||
val intent = Intent(Intent.ACTION_VIEW, uri).apply {
|
|
||||||
addCategory(Intent.CATEGORY_BROWSABLE)
|
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
|
||||||
|
fun rickRoll(context: Context) {
|
||||||
|
val uri = Uri.parse(context.getString(R.string.rick_roll_url))
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, uri).apply {
|
||||||
|
addCategory(Intent.CATEGORY_BROWSABLE)
|
||||||
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
}
|
}
|
||||||
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
|
|
||||||
<string-array name="rick_roll_domains" translatable="false">
|
<string-array name="rick_roll_domains" translatable="false">
|
||||||
<item>gab.com</item>
|
<item>gab.com</item>
|
||||||
|
<item>gab.ai</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="rick_roll_url">https://www.youtube.com/watch?v=dQw4w9WgXcQ</string>
|
<string name="rick_roll_url">https://www.youtube.com/watch?v=dQw4w9WgXcQ</string>
|
||||||
|
|
Loading…
Reference in New Issue