Add PlagiarismUtil

This commit is contained in:
Prathamesh More 2022-05-24 19:15:43 +05:30
parent c15bd77b39
commit cee51eb2cc
3 changed files with 44 additions and 17 deletions

View file

@ -20,7 +20,6 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.KeyEvent
import android.view.View
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
import androidx.core.os.ConfigurationCompat
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
@ -29,6 +28,7 @@ import code.name.monkey.retromusic.LanguageContextWrapper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.*
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.maybeShowAnnoyingToasts
import code.name.monkey.retromusic.util.theme.getNightMode
import code.name.monkey.retromusic.util.theme.getThemeResValue
import com.google.android.play.core.splitcompat.SplitCompat
@ -42,14 +42,15 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
updateTheme()
hideStatusBar()
super.onCreate(savedInstanceState)
println("OnCreate")
setEdgeToEdgeOrImmersive()
registerSystemUiVisibility()
maybeSetScreenOn()
setLightNavigationBarAuto()
setLightStatusBarAuto(surfaceColor())
if (VersionUtils.hasQ()) {
window.decorView.isForceDarkAllowed = false
}
maybeShowAnnoyingToasts()
}
private fun updateTheme() {
@ -74,20 +75,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
}
}
private fun registerSystemUiVisibility() {
val decorView = window.decorView
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
setImmersiveFullscreen()
}
}
}
private fun unregisterSystemUiVisibility() {
val decorView = window.decorView
decorView.setOnSystemUiVisibilityChangeListener(null)
}
override fun run() {
setImmersiveFullscreen()
}
@ -99,7 +86,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
public override fun onDestroy() {
super.onDestroy()
unregisterSystemUiVisibility()
exitFullscreen()
}

View file

@ -23,6 +23,7 @@ import androidx.navigation.navOptions
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
import code.name.monkey.retromusic.util.maybeShowAnnoyingToasts
/**
* Created by hemanths on 18/08/17.
@ -63,6 +64,7 @@ open class AbsMusicServiceFragment(@LayoutRes layout: Int) : Fragment(layout),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
serviceActivity?.addMusicServiceEventListener(this)
maybeShowAnnoyingToasts()
}
override fun onDestroyView() {

View file

@ -0,0 +1,39 @@
package code.name.monkey.retromusic.util
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.util.Log
import android.widget.Toast
import androidx.fragment.app.Fragment
import code.name.monkey.retromusic.BuildConfig
import code.name.monkey.retromusic.extensions.showToast
fun Activity.maybeShowAnnoyingToasts() {
if (BuildConfig.APPLICATION_ID != "code.name.monkey.retromusic" &&
BuildConfig.APPLICATION_ID != "code.name.monkey.retromusic.debug"
) {
if (BuildConfig.DEBUG) {
// Log these things to console, if the plagiarizer even cares to check it
Log.d("Retro Music", "What are you doing with your life?")
Log.d("Retro Music", "Stop copying apps and make use of your brain.")
Log.d("Retro Music", "Stop doing this or you will end up straight to hell.")
Log.d("Retro Music", "To the boiler room of hell. All the way down.")
} else {
showToast("Warning! This is a copy of Retro Music Player", Toast.LENGTH_LONG)
showToast("Instead of using this copy by a dumb person who didn't even bother to remove this code.", Toast.LENGTH_LONG)
showToast("Support us by downloading the original version from Play Store.", Toast.LENGTH_LONG)
val packageName = "code.name.monkey.retromusic"
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
}
}
}
}
fun Fragment.maybeShowAnnoyingToasts() {
requireActivity().maybeShowAnnoyingToasts()
}