UI: more interesting easter eggs
This commit is contained in:
parent
f9663c25e2
commit
3e2c0c3786
@ -1,12 +1,16 @@
|
|||||||
package io.neoterm
|
package io.neoterm
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.widget.Toast
|
||||||
import io.neoterm.component.NeoInitializer
|
import io.neoterm.component.NeoInitializer
|
||||||
import io.neoterm.frontend.preference.NeoPreference
|
import io.neoterm.frontend.preference.NeoPreference
|
||||||
|
import io.neoterm.ui.bonus.BonusActivity
|
||||||
import io.neoterm.utils.CrashHandler
|
import io.neoterm.utils.CrashHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +49,26 @@ class App : Application() {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
fun easterEgg(context: Context, message: String) {
|
||||||
|
val happyCount = NeoPreference.loadInt(NeoPreference.KEY_HAPPY_EGG, 0) + 1
|
||||||
|
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, happyCount)
|
||||||
|
|
||||||
|
val trigger = NeoPreference.VALUE_HAPPY_EGG_TRIGGER
|
||||||
|
|
||||||
|
if (happyCount == trigger / 2) {
|
||||||
|
@SuppressLint("ShowToast")
|
||||||
|
val toast = Toast.makeText(this, message, Toast.LENGTH_LONG)
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0)
|
||||||
|
toast.show()
|
||||||
|
} else if (happyCount > trigger) {
|
||||||
|
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, 0)
|
||||||
|
context.startActivity(Intent(context, BonusActivity::class.java))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
private var app: App? = null
|
private var app: App? = null
|
||||||
|
|
||||||
fun get(): App {
|
fun get(): App {
|
||||||
return app!!
|
return app!!
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ import android.view.View
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import de.psdev.licensesdialog.LicensesDialog
|
import de.psdev.licensesdialog.LicensesDialog
|
||||||
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20
|
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20
|
||||||
import de.psdev.licensesdialog.licenses.GnuGeneralPublicLicense20
|
|
||||||
import de.psdev.licensesdialog.licenses.GnuGeneralPublicLicense30
|
import de.psdev.licensesdialog.licenses.GnuGeneralPublicLicense30
|
||||||
import de.psdev.licensesdialog.licenses.MITLicense
|
import de.psdev.licensesdialog.licenses.MITLicense
|
||||||
import de.psdev.licensesdialog.model.Notice
|
import de.psdev.licensesdialog.model.Notice
|
||||||
import de.psdev.licensesdialog.model.Notices
|
import de.psdev.licensesdialog.model.Notices
|
||||||
|
import io.neoterm.App
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
} catch (ignored: PackageManager.NameNotFoundException) {
|
} catch (ignored: PackageManager.NameNotFoundException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<View>(R.id.developersView).setOnClickListener {
|
findViewById<View>(R.id.about_developers_view).setOnClickListener {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.about_developers_label)
|
.setTitle(R.string.about_developers_label)
|
||||||
.setMessage(R.string.about_developers)
|
.setMessage(R.string.about_developers)
|
||||||
@ -43,7 +43,7 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<View>(R.id.creditsView).setOnClickListener {
|
findViewById<View>(R.id.about_credits_view).setOnClickListener {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.about_credits_label)
|
.setTitle(R.string.about_credits_label)
|
||||||
.setMessage(R.string.about_credits)
|
.setMessage(R.string.about_credits)
|
||||||
@ -51,7 +51,7 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<View>(R.id.licensesView).setOnClickListener {
|
findViewById<View>(R.id.about_licenses_view).setOnClickListener {
|
||||||
val notices = Notices()
|
val notices = Notices()
|
||||||
notices.addNotice(Notice("ADBToolkitInstaller", "https://github.com/Crixec/ADBToolKitsInstaller", "Copyright (c) 2017 Crixec", GnuGeneralPublicLicense30()))
|
notices.addNotice(Notice("ADBToolkitInstaller", "https://github.com/Crixec/ADBToolKitsInstaller", "Copyright (c) 2017 Crixec", GnuGeneralPublicLicense30()))
|
||||||
notices.addNotice(Notice("Android-Terminal-Emulator", "https://github.com/jackpal/Android-Terminal-Emulator", "Copyright (c) 2011-2016 Steven Luo", ApacheSoftwareLicense20()))
|
notices.addNotice(Notice("Android-Terminal-Emulator", "https://github.com/jackpal/Android-Terminal-Emulator", "Copyright (c) 2011-2016 Steven Luo", ApacheSoftwareLicense20()))
|
||||||
@ -70,11 +70,15 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<View>(R.id.sourceCodeView).setOnClickListener {
|
findViewById<View>(R.id.about_version_view).setOnClickListener {
|
||||||
|
App.get().easterEgg(this, "Emmmmmm...")
|
||||||
|
}
|
||||||
|
|
||||||
|
findViewById<View>(R.id.about_source_code_view).setOnClickListener {
|
||||||
openUrl("https://github.com/NeoTerm/NeoTerm")
|
openUrl("https://github.com/NeoTerm/NeoTerm")
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<View>(R.id.donateView).setOnClickListener {
|
findViewById<View>(R.id.about_donate_view).setOnClickListener {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.support_donate_label)
|
.setTitle(R.string.support_donate_label)
|
||||||
.setMessage(R.string.support_donate_dialog_text)
|
.setMessage(R.string.support_donate_dialog_text)
|
||||||
|
@ -19,6 +19,7 @@ import android.view.inputmethod.InputMethodManager
|
|||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import de.mrapp.android.tabswitcher.*
|
import de.mrapp.android.tabswitcher.*
|
||||||
|
import io.neoterm.App
|
||||||
import io.neoterm.R
|
import io.neoterm.R
|
||||||
import io.neoterm.backend.TerminalSession
|
import io.neoterm.backend.TerminalSession
|
||||||
import io.neoterm.component.setup.BaseFileInstaller
|
import io.neoterm.component.setup.BaseFileInstaller
|
||||||
@ -544,20 +545,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
|||||||
|
|
||||||
private fun toggleSwitcher(showSwitcher: Boolean, easterEgg: Boolean) {
|
private fun toggleSwitcher(showSwitcher: Boolean, easterEgg: Boolean) {
|
||||||
if (tabSwitcher.count == 0 && easterEgg) {
|
if (tabSwitcher.count == 0 && easterEgg) {
|
||||||
val happyCount = NeoPreference.loadInt(NeoPreference.KEY_HAPPY_EGG, 0) + 1
|
App.get().easterEgg(this, "Stop! You don't know what you are doing!")
|
||||||
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, happyCount)
|
|
||||||
|
|
||||||
val trigger = NeoPreference.VALUE_HAPPY_EGG_TRIGGER
|
|
||||||
|
|
||||||
if (happyCount == trigger / 2) {
|
|
||||||
@SuppressLint("ShowToast")
|
|
||||||
val toast = Toast.makeText(this, "Stop! You don't know what you are doing!", Toast.LENGTH_LONG)
|
|
||||||
toast.setGravity(Gravity.CENTER, 0, 0)
|
|
||||||
toast.show()
|
|
||||||
} else if (happyCount > trigger) {
|
|
||||||
NeoPreference.store(NeoPreference.KEY_HAPPY_EGG, 0)
|
|
||||||
startActivity(Intent(this, BonusActivity::class.java))
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/about_version_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
@ -105,7 +106,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/developersView"
|
android:id="@+id/about_developers_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
@ -142,7 +143,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/creditsView"
|
android:id="@+id/about_credits_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
@ -179,7 +180,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/licensesView"
|
android:id="@+id/about_licenses_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
@ -209,7 +210,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/sourceCodeView"
|
android:id="@+id/about_source_code_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
@ -246,7 +247,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/donateView"
|
android:id="@+id/about_donate_view"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user