feat: commit to the prank...

This commit is contained in:
TwistedUmbrellaX 2024-03-20 19:15:07 -04:00
parent 125a95285d
commit 958aa634b1
4 changed files with 27 additions and 6 deletions

View file

@ -151,10 +151,10 @@ class App : MultiDexApplication() {
} }
companion object { companion object {
private var instance: App? = null
/** Reference to the application context. /** Reference to the application context.
* *
* USE WITH EXTREME CAUTION!**/ * USE WITH EXTREME CAUTION!**/
var instance: App? = null
var context: Context? = null var context: Context? = null
fun currentContext(): Context? { fun currentContext(): Context? {
return instance?.mFTActivityLifecycleCallbacks?.currentActivity ?: context return instance?.mFTActivityLifecycleCallbacks?.currentActivity ?: context

View file

@ -10,6 +10,7 @@ import android.app.PendingIntent
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
@ -718,6 +719,23 @@ fun openLinkInBrowser(link: String?) {
} }
} }
fun openLinkInYouTube(link: String?) {
link?.let {
try {
val videoIntent = Intent(Intent.ACTION_VIEW).apply {
addCategory(Intent.CATEGORY_BROWSABLE)
data = Uri.parse(link)
setPackage("com.google.android.youtube")
}
currContext()!!.startActivity(videoIntent)
} catch (e: ActivityNotFoundException) {
openLinkInBrowser(link)
} catch (e: Exception) {
Logger.log(e)
}
}
}
fun saveImageToDownloads(title: String, bitmap: Bitmap, context: Activity) { fun saveImageToDownloads(title: String, bitmap: Bitmap, context: Activity) {
FileProvider.getUriForFile( FileProvider.getUriForFile(
context, context,
@ -1007,7 +1025,7 @@ class EmptyAdapter(private val count: Int) : RecyclerView.Adapter<RecyclerView.V
} }
fun getAppString(res: Int): String { fun getAppString(res: Int): String {
return App.instance?.getString(res) ?: "" return currContext()!!.getString(res) ?: ""
} }
fun toast(string: String?) { fun toast(string: String?) {

View file

@ -3,6 +3,7 @@ package ani.dantotsu.settings
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.AlarmManager import android.app.AlarmManager
import android.app.AlertDialog import android.app.AlertDialog
import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.drawable.Animatable import android.graphics.drawable.Animatable
@ -59,10 +60,11 @@ import ani.dantotsu.loadImage
import ani.dantotsu.util.Logger import ani.dantotsu.util.Logger
import ani.dantotsu.navBarHeight import ani.dantotsu.navBarHeight
import ani.dantotsu.notifications.TaskScheduler import ani.dantotsu.notifications.TaskScheduler
import ani.dantotsu.notifications.comment.CommentNotificationWorker
import ani.dantotsu.notifications.anilist.AnilistNotificationWorker import ani.dantotsu.notifications.anilist.AnilistNotificationWorker
import ani.dantotsu.notifications.comment.CommentNotificationWorker
import ani.dantotsu.notifications.subscription.SubscriptionNotificationWorker.Companion.checkIntervals import ani.dantotsu.notifications.subscription.SubscriptionNotificationWorker.Companion.checkIntervals
import ani.dantotsu.openLinkInBrowser import ani.dantotsu.openLinkInBrowser
import ani.dantotsu.openLinkInYouTube
import ani.dantotsu.openSettings import ani.dantotsu.openSettings
import ani.dantotsu.others.AppUpdater import ani.dantotsu.others.AppUpdater
import ani.dantotsu.others.CustomBottomDialog import ani.dantotsu.others.CustomBottomDialog
@ -641,9 +643,8 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
cursedCounter++ cursedCounter++
(binding.settingsLogo.drawable as Animatable).start() (binding.settingsLogo.drawable as Animatable).start()
if (cursedCounter % 7 == 0) { if (cursedCounter % 7 == 0) {
Toast.makeText(this, "youwu have been cuwsed :pwayge:", Toast.LENGTH_LONG).show() toast(R.string.you_cursed)
val url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" openLinkInYouTube(getString(R.string.cursed_yt))
openLinkInBrowser(url)
//PrefManager.setVal(PrefName.ImageUrl, !PrefManager.getVal(PrefName.ImageUrl, false)) //PrefManager.setVal(PrefName.ImageUrl, !PrefManager.getVal(PrefName.ImageUrl, false))
} else { } else {
snackString(array[(Math.random() * array.size).toInt()], this) snackString(array[(Math.random() * array.size).toInt()], this)

View file

@ -723,6 +723,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="comment_notification_checking_time">Comment notifications update frequency : %1$s</string> <string name="comment_notification_checking_time">Comment notifications update frequency : %1$s</string>
<string name="activities">Activities</string> <string name="activities">Activities</string>
<string name="you_cursed">youwu have been cuwsed :pwayge:</string>
<string name="cursed_yt">https://www.youtube.com/watch?v=dQw4w9WgXcQ</string>
<string name="purge_confirm">Are you sure you want to purge all %1$s downloads?</string> <string name="purge_confirm">Are you sure you want to purge all %1$s downloads?</string>
<string name="delete_fail_reason">Failed to delete because of… %1$s</string> <string name="delete_fail_reason">Failed to delete because of… %1$s</string>