mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-09 19:50:26 -06:00
[App] Simplify enabling Dev Mode on nightly builds
This commit is contained in:
parent
c5b173b40a
commit
ddefda08f1
@ -78,7 +78,7 @@ class BuildManager(val app: App) : CoroutineScope {
|
|||||||
val isOfficial = isSigned && (isPlayRelease || isApkRelease)
|
val isOfficial = isSigned && (isPlayRelease || isApkRelease)
|
||||||
|
|
||||||
val versionName = when {
|
val versionName = when {
|
||||||
isOfficial -> BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE
|
isOfficial -> BuildConfig.VERSION_NAME
|
||||||
isRelease -> "$gitVersion\n$gitBranch"
|
isRelease -> "$gitVersion\n$gitBranch"
|
||||||
else -> BuildConfig.VERSION_NAME
|
else -> BuildConfig.VERSION_NAME
|
||||||
}
|
}
|
||||||
@ -103,6 +103,8 @@ class BuildManager(val app: App) : CoroutineScope {
|
|||||||
else -> Update.Type.RELEASE
|
else -> Update.Type.RELEASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val devModeEasy = (isDaily || isNightly || isDebug) && !App.devMode
|
||||||
|
|
||||||
fun fetchInstalledTime() {
|
fun fetchInstalledTime() {
|
||||||
if (app.config.appInstalledTime != 0L)
|
if (app.config.appInstalledTime != 0L)
|
||||||
return
|
return
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kuba Szczodrzyński 2024-7-5.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.ui.dialogs
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import pl.szczodrzynski.edziennik.App
|
||||||
|
import pl.szczodrzynski.edziennik.R
|
||||||
|
import pl.szczodrzynski.edziennik.ui.base.dialog.BaseDialog
|
||||||
|
|
||||||
|
class DevModeDialog(
|
||||||
|
activity: AppCompatActivity,
|
||||||
|
) : BaseDialog<Unit>(activity) {
|
||||||
|
|
||||||
|
override fun getTitleRes() = R.string.are_you_sure
|
||||||
|
override fun getMessageRes() = R.string.dev_mode_enable_warning
|
||||||
|
override fun isCancelable() = false
|
||||||
|
override fun getPositiveButtonText() = R.string.yes
|
||||||
|
override fun getNegativeButtonText() = R.string.no
|
||||||
|
|
||||||
|
override suspend fun onPositiveClick(): Boolean {
|
||||||
|
app.config.devMode = true
|
||||||
|
if (!App.devMode) {
|
||||||
|
RestartDialog(activity).showModal()
|
||||||
|
return NO_DISMISS
|
||||||
|
}
|
||||||
|
return DISMISS
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun onNegativeClick(): Boolean {
|
||||||
|
app.config.devMode = null
|
||||||
|
if (App.devMode) {
|
||||||
|
RestartDialog(activity).showModal()
|
||||||
|
return NO_DISMISS
|
||||||
|
}
|
||||||
|
return DISMISS
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ import android.view.animation.AccelerateDecelerateInterpolator
|
|||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.view.animation.RotateAnimation
|
import android.view.animation.RotateAnimation
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@ -37,6 +38,7 @@ import pl.szczodrzynski.edziennik.ext.resolveColor
|
|||||||
import pl.szczodrzynski.edziennik.ext.setText
|
import pl.szczodrzynski.edziennik.ext.setText
|
||||||
import pl.szczodrzynski.edziennik.ext.setTintColor
|
import pl.szczodrzynski.edziennik.ext.setTintColor
|
||||||
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.sync.RegisterUnavailableDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.sync.RegisterUnavailableDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.feedback.FeedbackActivity
|
import pl.szczodrzynski.edziennik.ui.feedback.FeedbackActivity
|
||||||
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
||||||
@ -86,6 +88,10 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
|
|||||||
Date.fromMillis(app.buildManager.buildTimestamp).stringY_m_d
|
Date.fromMillis(app.buildManager.buildTimestamp).stringY_m_d
|
||||||
)
|
)
|
||||||
b.versionText.onClick {
|
b.versionText.onClick {
|
||||||
|
if (app.buildManager.devModeEasy) {
|
||||||
|
DevModeDialog(activity).show()
|
||||||
|
return@onClick
|
||||||
|
}
|
||||||
app.buildManager.showVersionDialog(activity)
|
app.buildManager.showVersionDialog(activity)
|
||||||
if (!App.devMode)
|
if (!App.devMode)
|
||||||
return@onClick
|
return@onClick
|
||||||
@ -238,7 +244,7 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// there are no profiles
|
// there are no profiles
|
||||||
b.cancelButton.isVisible = false
|
b.cancelButton.isInvisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,14 @@ import coil.load
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.BuildConfig
|
import pl.szczodrzynski.edziennik.BuildConfig
|
||||||
import pl.szczodrzynski.edziennik.R
|
import pl.szczodrzynski.edziennik.R
|
||||||
import pl.szczodrzynski.edziennik.databinding.LoginPrizeFragmentBinding
|
import pl.szczodrzynski.edziennik.databinding.LoginPrizeFragmentBinding
|
||||||
import pl.szczodrzynski.edziennik.ext.onClick
|
import pl.szczodrzynski.edziennik.ext.onClick
|
||||||
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
@ -49,20 +51,10 @@ class LoginPrizeFragment : Fragment(), CoroutineScope {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
b.button.load("https://szkolny.eu/game/button.png")
|
b.button.load("https://szkolny.eu/game/button.png")
|
||||||
b.button.onClick {
|
b.button.onClick {
|
||||||
SimpleDialog<Unit>(activity) {
|
launch {
|
||||||
title(R.string.are_you_sure)
|
DevModeDialog(activity).showModal()
|
||||||
message(R.string.dev_mode_enable_warning)
|
activity.finish()
|
||||||
positive(R.string.yes) {
|
}
|
||||||
app.config.devMode = true
|
|
||||||
App.devMode = true
|
|
||||||
RestartDialog(activity).show()
|
|
||||||
}
|
|
||||||
negative(R.string.no) {
|
|
||||||
app.config.devMode = BuildConfig.DEBUG
|
|
||||||
App.devMode = BuildConfig.DEBUG
|
|
||||||
activity.finish()
|
|
||||||
}
|
|
||||||
}.show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import pl.szczodrzynski.edziennik.data.enums.NavTarget
|
|||||||
import pl.szczodrzynski.edziennik.ext.after
|
import pl.szczodrzynski.edziennik.ext.after
|
||||||
import pl.szczodrzynski.edziennik.ext.resolveAttr
|
import pl.szczodrzynski.edziennik.ext.resolveAttr
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.ChangelogDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.ChangelogDialog
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.settings.SettingsCard
|
import pl.szczodrzynski.edziennik.ui.settings.SettingsCard
|
||||||
import pl.szczodrzynski.edziennik.ui.settings.SettingsLicenseActivity
|
import pl.szczodrzynski.edziennik.ui.settings.SettingsLicenseActivity
|
||||||
import pl.szczodrzynski.edziennik.ui.settings.SettingsUtil
|
import pl.szczodrzynski.edziennik.ui.settings.SettingsUtil
|
||||||
@ -69,7 +70,7 @@ class SettingsAboutCard(util: SettingsUtil) : SettingsCard(util), CoroutineScope
|
|||||||
card.items.after(item, versionDetailsItem)
|
card.items.after(item, versionDetailsItem)
|
||||||
util.refresh()
|
util.refresh()
|
||||||
}
|
}
|
||||||
|
// eggs
|
||||||
clickCounter++
|
clickCounter++
|
||||||
if (clickCounter < 7)
|
if (clickCounter < 7)
|
||||||
Toast.makeText(activity, "\uD83D\uDE02", Toast.LENGTH_SHORT).show()
|
Toast.makeText(activity, "\uD83D\uDE02", Toast.LENGTH_SHORT).show()
|
||||||
@ -79,10 +80,13 @@ class SettingsAboutCard(util: SettingsUtil) : SettingsCard(util), CoroutineScope
|
|||||||
if (clickCounter >= 7) {
|
if (clickCounter >= 7) {
|
||||||
mediaPlayer.start()
|
mediaPlayer.start()
|
||||||
clickCounter = 0
|
clickCounter = 0
|
||||||
|
if (app.buildManager.devModeEasy) {
|
||||||
|
DevModeDialog(activity).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).also {
|
).also {
|
||||||
it.subText = BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE
|
it.subText = BuildConfig.VERSION_NAME
|
||||||
},
|
},
|
||||||
|
|
||||||
util.createActionItem(
|
util.createActionItem(
|
||||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.ext.onClick
|
|||||||
import pl.szczodrzynski.edziennik.ext.onLongClick
|
import pl.szczodrzynski.edziennik.ext.onLongClick
|
||||||
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.base.fragment.PagerFragment
|
import pl.szczodrzynski.edziennik.ui.base.fragment.PagerFragment
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
||||||
|
|
||||||
class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActivity>(
|
class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActivity>(
|
||||||
@ -40,6 +41,7 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
|||||||
} to getString(R.string.translators),
|
} to getString(R.string.translators),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// eggs
|
||||||
/*private var konami = 0
|
/*private var konami = 0
|
||||||
|
|
||||||
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
@ -67,6 +69,7 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
|||||||
b.tabLayout.isVisible = false
|
b.tabLayout.isVisible = false
|
||||||
b.viewPager.isVisible = false
|
b.viewPager.isVisible = false
|
||||||
|
|
||||||
|
// eggs
|
||||||
b.szkolny.onLongClick {
|
b.szkolny.onLongClick {
|
||||||
if (b.konami.isVisible) {
|
if (b.konami.isVisible) {
|
||||||
b.glove.isVisible = true
|
b.glove.isVisible = true
|
||||||
@ -74,21 +77,8 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
b.glove.onClick {
|
b.glove.onClick {
|
||||||
SimpleDialog<Unit>(activity) {
|
DevModeDialog(activity).show()
|
||||||
title(R.string.are_you_sure)
|
|
||||||
message(R.string.dev_mode_enable_warning)
|
|
||||||
positive(R.string.yes) {
|
|
||||||
app.config.devMode = true
|
|
||||||
App.devMode = true
|
|
||||||
RestartDialog(activity).show()
|
|
||||||
}
|
|
||||||
negative(R.string.no) {
|
|
||||||
app.config.devMode = false
|
|
||||||
App.devMode = false
|
|
||||||
}
|
|
||||||
}.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contributors = contributors ?: SzkolnyApi(app).runCatching(activity.errorSnackbar) {
|
contributors = contributors ?: SzkolnyApi(app).runCatching(activity.errorSnackbar) {
|
||||||
|
Loading…
Reference in New Issue
Block a user