rick roll instead of logging in on selected domains
This commit is contained in:
parent
91d01bce05
commit
ee35a9768f
3 changed files with 31 additions and 0 deletions
|
@ -33,6 +33,7 @@ import com.keylesspalace.tusky.di.Injectable
|
|||
import com.keylesspalace.tusky.entity.AccessToken
|
||||
import com.keylesspalace.tusky.entity.AppCredentials
|
||||
import com.keylesspalace.tusky.network.MastodonApi
|
||||
import com.keylesspalace.tusky.util.RickRoll
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import kotlinx.android.synthetic.main.activity_login.*
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -138,6 +139,11 @@ class LoginActivity : BaseActivity(), Injectable {
|
|||
return
|
||||
}
|
||||
|
||||
if (RickRoll.shouldRickRoll(this, domain)) {
|
||||
RickRoll.rickRoll(this)
|
||||
return
|
||||
}
|
||||
|
||||
val callback = object : Callback<AppCredentials> {
|
||||
override fun onResponse(call: Call<AppCredentials>,
|
||||
response: Response<AppCredentials>) {
|
||||
|
|
20
app/src/main/java/com/keylesspalace/tusky/util/RickRoll.kt
Normal file
20
app/src/main/java/com/keylesspalace/tusky/util/RickRoll.kt
Normal file
|
@ -0,0 +1,20 @@
|
|||
package com.keylesspalace.tusky.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import com.keylesspalace.tusky.R
|
||||
|
||||
object RickRoll {
|
||||
fun shouldRickRoll(context: Context, domain: String) =
|
||||
context.resources.getStringArray(R.array.rick_roll_domains).contains(domain)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -105,4 +105,9 @@
|
|||
%1$s; %2$s; %3$s, %13$s %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
|
||||
</string>
|
||||
|
||||
<string-array name="rick_roll_domains" translatable="false">
|
||||
<item>gab.com</item>
|
||||
</string-array>
|
||||
|
||||
<string name="rick_roll_url">https://www.youtube.com/watch?v=dQw4w9WgXcQ</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue