splash screen
This commit is contained in:
parent
9940578aee
commit
3870ebaa53
|
@ -63,6 +63,7 @@ import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
|
|||
import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.events.EventAppExit
|
||||
import info.nightscout.rx.events.EventAppInitialized
|
||||
import info.nightscout.rx.events.EventPreferenceChange
|
||||
import info.nightscout.rx.events.EventRebuildTabs
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
@ -134,10 +135,6 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
}
|
||||
})
|
||||
|
||||
//Check here if loop plugin is disabled. Else check via constraints
|
||||
if (!(loop as PluginBase).isEnabled()) versionCheckerUtils.triggerCheckVersion()
|
||||
setUserStats()
|
||||
setupViews()
|
||||
disposable += rxBus
|
||||
.toObservable(EventRebuildTabs::class.java)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
@ -150,6 +147,36 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
.subscribe({ processPreferenceChange(it) }, fabricPrivacy::logException)
|
||||
disposable += rxBus
|
||||
.toObservable(EventAppInitialized::class.java)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
.subscribe({
|
||||
// 1st run of app
|
||||
start()
|
||||
}, fabricPrivacy::logException)
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (binding.mainDrawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
binding.mainDrawerLayout.closeDrawers()
|
||||
else if (menuOpen)
|
||||
menu?.close()
|
||||
else if (binding.mainPager.currentItem != 0)
|
||||
binding.mainPager.currentItem = 0
|
||||
else finish()
|
||||
}
|
||||
})
|
||||
// Setup views on 2nd and next activity start
|
||||
// On 1st start app is still initializing, start() is delayed and run from EventAppInitialized
|
||||
if (config.appInitialized) start()
|
||||
}
|
||||
|
||||
private fun start() {
|
||||
binding.splash.visibility = View.GONE
|
||||
//Check here if loop plugin is disabled. Else check via constraints
|
||||
if (!(loop as PluginBase).isEnabled()) versionCheckerUtils.triggerCheckVersion()
|
||||
setUserStats()
|
||||
setupViews()
|
||||
|
||||
if (startWizard() && !isRunningRealPumpTest()) {
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||
startActivity(Intent(this, SetupWizardActivity::class.java).setAction("info.nightscout.androidaps.MainActivity"))
|
||||
|
@ -164,17 +191,6 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
androidPermission.notifyForBtConnectPermission(this)
|
||||
}
|
||||
passwordResetCheck(this)
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (binding.mainDrawerLayout.isDrawerOpen(GravityCompat.START))
|
||||
binding.mainDrawerLayout.closeDrawers()
|
||||
else if (menuOpen)
|
||||
menu?.close()
|
||||
else if (binding.mainPager.currentItem != 0)
|
||||
binding.mainPager.currentItem = 0
|
||||
else finish()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun checkPluginPreferences(viewPager: ViewPager2) {
|
||||
|
@ -196,6 +212,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (config.appInitialized) binding.splash.visibility = View.GONE
|
||||
if (!isProtectionCheckActive) {
|
||||
isProtectionCheckActive = true
|
||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, UIRunnable { isProtectionCheckActive = false },
|
||||
|
@ -321,9 +338,6 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
|
|||
this.menu = menu
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
pluginPreferencesMenuItem = menu.findItem(R.id.nav_plugin_preferences)
|
||||
setPluginPreferenceMenuName()
|
||||
checkPluginPreferences(binding.mainPager)
|
||||
setDisabledMenuItemColorPluginPreferences()
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,10 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
|
|||
import io.reactivex.rxjava3.exceptions.UndeliverableException
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import rxdogtag2.RxDogTag
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -83,77 +87,81 @@ class MainApp : DaggerApplication() {
|
|||
|
||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
private lateinit var refreshWidget: Runnable
|
||||
private val scope = CoroutineScope(Dispatchers.Default + Job())
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
aapsLogger.debug("onCreate")
|
||||
RxDogTag.install()
|
||||
setRxErrorHandler()
|
||||
LocaleHelper.update(this)
|
||||
|
||||
var gitRemote: String? = BuildConfig.REMOTE
|
||||
var commitHash: String? = BuildConfig.HEAD
|
||||
if (gitRemote?.contains("NoGitSystemAvailable") == true) {
|
||||
gitRemote = null
|
||||
commitHash = null
|
||||
}
|
||||
disposable += compatDBHelper.dbChangeDisposable()
|
||||
registerActivityLifecycleCallbacks(activityMonitor)
|
||||
profileSwitchPlugin.setThemeMode()
|
||||
aapsLogger.debug("Version: " + BuildConfig.VERSION_NAME)
|
||||
aapsLogger.debug("BuildVersion: " + BuildConfig.BUILDVERSION)
|
||||
aapsLogger.debug("Remote: " + BuildConfig.REMOTE)
|
||||
registerLocalBroadcastReceiver()
|
||||
|
||||
// trigger here to see the new version on app start after an update
|
||||
versionCheckersUtils.triggerCheckVersion()
|
||||
|
||||
// Register all tabs in app here
|
||||
pluginStore.plugins = plugins
|
||||
configBuilder.initialize()
|
||||
|
||||
// delayed actions to make rh context updated for translations
|
||||
handler.postDelayed(
|
||||
{
|
||||
// check if identification is set
|
||||
if (config.isDev() && sp.getStringOrNull(info.nightscout.core.utils.R.string.key_email_for_crash_report, null).isNullOrBlank())
|
||||
notificationStore.add(Notification(Notification.IDENTIFICATION_NOT_SET, rh.get().gs(R.string.identification_not_set), Notification.INFO))
|
||||
// log version
|
||||
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe()
|
||||
// log app start
|
||||
if (sp.getBoolean(info.nightscout.plugins.sync.R.string.key_ns_log_app_started_event, config.APS))
|
||||
disposable += repository
|
||||
.runTransaction(
|
||||
InsertIfNewByTimestampTherapyEventTransaction(
|
||||
timestamp = dateUtil.now(),
|
||||
type = TherapyEvent.Type.NOTE,
|
||||
note = rh.get().gs(info.nightscout.core.ui.R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL,
|
||||
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||
)
|
||||
)
|
||||
.subscribe()
|
||||
}, 10000
|
||||
)
|
||||
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
|
||||
KeepAliveWorker.KA_0,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
PeriodicWorkRequest.Builder(KeepAliveWorker::class.java, 15, TimeUnit.MINUTES)
|
||||
.setInputData(Data.Builder().putString("schedule", KeepAliveWorker.KA_0).build())
|
||||
.setInitialDelay(5, TimeUnit.SECONDS)
|
||||
.build()
|
||||
)
|
||||
localAlertUtils.shortenSnoozeInterval()
|
||||
localAlertUtils.preSnoozeAlarms()
|
||||
doMigrations()
|
||||
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(processLifecycleListener.get())
|
||||
scope.launch {
|
||||
RxDogTag.install()
|
||||
setRxErrorHandler()
|
||||
LocaleHelper.update(this@MainApp)
|
||||
|
||||
// schedule widget update
|
||||
refreshWidget = Runnable {
|
||||
var gitRemote: String? = BuildConfig.REMOTE
|
||||
var commitHash: String? = BuildConfig.HEAD
|
||||
if (gitRemote?.contains("NoGitSystemAvailable") == true) {
|
||||
gitRemote = null
|
||||
commitHash = null
|
||||
}
|
||||
disposable += compatDBHelper.dbChangeDisposable()
|
||||
registerActivityLifecycleCallbacks(activityMonitor)
|
||||
profileSwitchPlugin.setThemeMode()
|
||||
aapsLogger.debug("Version: " + BuildConfig.VERSION_NAME)
|
||||
aapsLogger.debug("BuildVersion: " + BuildConfig.BUILDVERSION)
|
||||
aapsLogger.debug("Remote: " + BuildConfig.REMOTE)
|
||||
registerLocalBroadcastReceiver()
|
||||
|
||||
// trigger here to see the new version on app start after an update
|
||||
versionCheckersUtils.triggerCheckVersion()
|
||||
|
||||
// Register all tabs in app here
|
||||
pluginStore.plugins = plugins
|
||||
configBuilder.initialize()
|
||||
|
||||
// delayed actions to make rh context updated for translations
|
||||
handler.postDelayed(
|
||||
{
|
||||
// check if identification is set
|
||||
if (config.isDev() && sp.getStringOrNull(info.nightscout.core.utils.R.string.key_email_for_crash_report, null).isNullOrBlank())
|
||||
notificationStore.add(Notification(Notification.IDENTIFICATION_NOT_SET, rh.get().gs(R.string.identification_not_set), Notification.INFO))
|
||||
// log version
|
||||
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe()
|
||||
// log app start
|
||||
if (sp.getBoolean(info.nightscout.plugins.sync.R.string.key_ns_log_app_started_event, config.APS))
|
||||
disposable += repository
|
||||
.runTransaction(
|
||||
InsertIfNewByTimestampTherapyEventTransaction(
|
||||
timestamp = dateUtil.now(),
|
||||
type = TherapyEvent.Type.NOTE,
|
||||
note = rh.get().gs(info.nightscout.core.ui.R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL,
|
||||
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||
)
|
||||
)
|
||||
.subscribe()
|
||||
}, 10000
|
||||
)
|
||||
WorkManager.getInstance(this@MainApp).enqueueUniquePeriodicWork(
|
||||
KeepAliveWorker.KA_0,
|
||||
ExistingPeriodicWorkPolicy.UPDATE,
|
||||
PeriodicWorkRequest.Builder(KeepAliveWorker::class.java, 15, TimeUnit.MINUTES)
|
||||
.setInputData(Data.Builder().putString("schedule", KeepAliveWorker.KA_0).build())
|
||||
.setInitialDelay(5, TimeUnit.SECONDS)
|
||||
.build()
|
||||
)
|
||||
localAlertUtils.shortenSnoozeInterval()
|
||||
localAlertUtils.preSnoozeAlarms()
|
||||
doMigrations()
|
||||
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)
|
||||
|
||||
// schedule widget update
|
||||
refreshWidget = Runnable {
|
||||
handler.postDelayed(refreshWidget, 60000)
|
||||
Widget.updateWidget(this@MainApp, "ScheduleEveryMin")
|
||||
}
|
||||
handler.postDelayed(refreshWidget, 60000)
|
||||
Widget.updateWidget(this, "ScheduleEveryMin")
|
||||
config.appInitialized = true
|
||||
}
|
||||
handler.postDelayed(refreshWidget, 60000)
|
||||
}
|
||||
|
||||
private fun setRxErrorHandler() {
|
||||
|
|
|
@ -35,6 +35,8 @@ class ConfigImpl @Inject constructor(
|
|||
Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.DEVICE + ")"
|
||||
override val appName: Int = R.string.app_name
|
||||
|
||||
override var appInitialized: Boolean = false
|
||||
|
||||
private var devBranch = false
|
||||
private var engineeringMode = false
|
||||
private var unfinishedMode = false
|
||||
|
|
|
@ -7,6 +7,28 @@
|
|||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/splash"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="30dp"
|
||||
android:text="@string/loading"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
app:srcCompat="@drawable/splash_logo" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -57,4 +79,4 @@
|
|||
app:itemTextColor="?android:textColorPrimary"/>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,6 +20,8 @@ interface Config {
|
|||
val currentDeviceModelString : String
|
||||
val appName: Int
|
||||
|
||||
var appInitialized: Boolean
|
||||
|
||||
fun isEngineeringModeOrRelease(): Boolean
|
||||
fun isEngineeringMode(): Boolean
|
||||
fun isUnfinishedMode(): Boolean
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- The android:opacity=”opaque” line — this is critical in preventing a flash of black as your theme transitions. -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
|
||||
|
||||
<!-- The background color, preferably the same as your normal theme -->
|
||||
<item android:drawable="?attr/splashBackgroundColor"/>
|
||||
|
||||
<!-- Your product logo - 144dp color version of your app icon -->
|
||||
<item>
|
||||
|
||||
<bitmap
|
||||
android:src="@drawable/splash_icon"
|
||||
android:gravity="center"/>
|
||||
|
||||
</item>
|
||||
|
||||
</layer-list>
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
86
core/ui/src/main/res/drawable/splash_logo.xml
Normal file
86
core/ui/src/main/res/drawable/splash_logo.xml
Normal file
File diff suppressed because one or more lines are too long
|
@ -21,8 +21,6 @@
|
|||
<item name="colorOnBackground">@color/white</item>
|
||||
<item name="colorOnError">@color/black</item>
|
||||
<item name="scrimBackground">@color/mtrl_scrim_color</item>
|
||||
<!---Splash Background -->
|
||||
<item name="splashBackgroundColor">@color/splashBackground</item>
|
||||
<!---Application Background Color -->
|
||||
<item name="android:windowBackground">@color/black</item>
|
||||
<!---Text Colors -->
|
||||
|
@ -399,7 +397,6 @@
|
|||
|
||||
<!-- The launcher theme. It sets the main window background to the launch_screen drawable -->
|
||||
<style name="AppTheme.Launcher" parent="AppTheme.NoActionBar">
|
||||
<item name="android:windowBackground">@drawable/launch_screen</item>
|
||||
</style>
|
||||
|
||||
<style name="section_header_label">
|
||||
|
|
|
@ -75,8 +75,6 @@
|
|||
<attr name="notificationLow" format="reference|color" />
|
||||
<attr name="notificationInfo" format="reference|color" />
|
||||
<attr name="notificationAnnouncement" format="reference|color" />
|
||||
<!---Splash Background -->
|
||||
<attr name="splashBackgroundColor" format="reference|color" />
|
||||
<!---Disabled Text Color -->
|
||||
<attr name="disabledTextColor" format="reference|color" />
|
||||
<!---Overview and History browser -->
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
<item name="colorPrimaryVariant">@color/primaryLightColorDefault</item>
|
||||
<item name="colorSecondaryVariant">@color/secondaryLightColorDefault</item>
|
||||
<item name="scrimBackground">@color/mtrl_scrim_color</item>
|
||||
<!---Splash Background -->
|
||||
<item name="splashBackgroundColor">@color/aaps_theme_light_background</item>
|
||||
<!---Application Background Color -->
|
||||
<item name="android:windowBackground">@color/aaps_theme_light_background</item>
|
||||
<!---Text Colors -->
|
||||
|
@ -409,7 +407,6 @@
|
|||
|
||||
<!-- The launcher theme. It sets the main window background to the launch_screen drawable -->
|
||||
<style name="AppTheme.Launcher" parent="AppTheme.NoActionBar">
|
||||
<item name="android:windowBackground">@drawable/launch_screen</item>
|
||||
</style>
|
||||
|
||||
<style name="section_header_label">
|
||||
|
|
Loading…
Reference in a new issue