mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 04:46:44 -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 versionName = when {
|
||||
isOfficial -> BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE
|
||||
isOfficial -> BuildConfig.VERSION_NAME
|
||||
isRelease -> "$gitVersion\n$gitBranch"
|
||||
else -> BuildConfig.VERSION_NAME
|
||||
}
|
||||
@ -103,6 +103,8 @@ class BuildManager(val app: App) : CoroutineScope {
|
||||
else -> Update.Type.RELEASE
|
||||
}
|
||||
|
||||
val devModeEasy = (isDaily || isNightly || isDebug) && !App.devMode
|
||||
|
||||
fun fetchInstalledTime() {
|
||||
if (app.config.appInstalledTime != 0L)
|
||||
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.RotateAnimation
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
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.setTintColor
|
||||
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.feedback.FeedbackActivity
|
||||
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
||||
@ -86,6 +88,10 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
|
||||
Date.fromMillis(app.buildManager.buildTimestamp).stringY_m_d
|
||||
)
|
||||
b.versionText.onClick {
|
||||
if (app.buildManager.devModeEasy) {
|
||||
DevModeDialog(activity).show()
|
||||
return@onClick
|
||||
}
|
||||
app.buildManager.showVersionDialog(activity)
|
||||
if (!App.devMode)
|
||||
return@onClick
|
||||
@ -238,7 +244,7 @@ class LoginChooserFragment : Fragment(), CoroutineScope {
|
||||
}
|
||||
else -> {
|
||||
// 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.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.BuildConfig
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.LoginPrizeFragmentBinding
|
||||
import pl.szczodrzynski.edziennik.ext.onClick
|
||||
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
@ -49,20 +51,10 @@ class LoginPrizeFragment : Fragment(), CoroutineScope {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
b.button.load("https://szkolny.eu/game/button.png")
|
||||
b.button.onClick {
|
||||
SimpleDialog<Unit>(activity) {
|
||||
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 = BuildConfig.DEBUG
|
||||
App.devMode = BuildConfig.DEBUG
|
||||
launch {
|
||||
DevModeDialog(activity).showModal()
|
||||
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.resolveAttr
|
||||
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.SettingsLicenseActivity
|
||||
import pl.szczodrzynski.edziennik.ui.settings.SettingsUtil
|
||||
@ -69,7 +70,7 @@ class SettingsAboutCard(util: SettingsUtil) : SettingsCard(util), CoroutineScope
|
||||
card.items.after(item, versionDetailsItem)
|
||||
util.refresh()
|
||||
}
|
||||
|
||||
// eggs
|
||||
clickCounter++
|
||||
if (clickCounter < 7)
|
||||
Toast.makeText(activity, "\uD83D\uDE02", Toast.LENGTH_SHORT).show()
|
||||
@ -79,10 +80,13 @@ class SettingsAboutCard(util: SettingsUtil) : SettingsCard(util), CoroutineScope
|
||||
if (clickCounter >= 7) {
|
||||
mediaPlayer.start()
|
||||
clickCounter = 0
|
||||
if (app.buildManager.devModeEasy) {
|
||||
DevModeDialog(activity).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
).also {
|
||||
it.subText = BuildConfig.VERSION_NAME + ", " + BuildConfig.BUILD_TYPE
|
||||
it.subText = BuildConfig.VERSION_NAME
|
||||
},
|
||||
|
||||
util.createActionItem(
|
||||
|
@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.ext.onClick
|
||||
import pl.szczodrzynski.edziennik.ext.onLongClick
|
||||
import pl.szczodrzynski.edziennik.ui.base.dialog.SimpleDialog
|
||||
import pl.szczodrzynski.edziennik.ui.base.fragment.PagerFragment
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.DevModeDialog
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.RestartDialog
|
||||
|
||||
class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActivity>(
|
||||
@ -40,6 +41,7 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
||||
} to getString(R.string.translators),
|
||||
)
|
||||
|
||||
// eggs
|
||||
/*private var konami = 0
|
||||
|
||||
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
||||
@ -67,6 +69,7 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
||||
b.tabLayout.isVisible = false
|
||||
b.viewPager.isVisible = false
|
||||
|
||||
// eggs
|
||||
b.szkolny.onLongClick {
|
||||
if (b.konami.isVisible) {
|
||||
b.glove.isVisible = true
|
||||
@ -74,21 +77,8 @@ class ContributorsFragment : PagerFragment<ContributorsFragmentBinding, MainActi
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
b.glove.onClick {
|
||||
SimpleDialog<Unit>(activity) {
|
||||
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()
|
||||
DevModeDialog(activity).show()
|
||||
}
|
||||
|
||||
contributors = contributors ?: SzkolnyApi(app).runCatching(activity.errorSnackbar) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user