mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-01-31 10:44:52 +01:00
properly handle SHOW_ALARMS intent
This commit is contained in:
parent
f399a3506a
commit
b2441efee4
@ -28,6 +28,11 @@
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SHOW_ALARMS"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -10,6 +10,7 @@ import com.simplemobiletools.clock.BuildConfig
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.adapters.ViewPagerAdapter
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.helpers.OPEN_TAB
|
||||
import com.simplemobiletools.clock.helpers.TABS_COUNT
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_NUMBER_PICKER
|
||||
@ -103,7 +104,9 @@ class MainActivity : SimpleActivity() {
|
||||
main_tabs_holder.getTabAt(it)?.select()
|
||||
}
|
||||
|
||||
viewpager.currentItem = config.lastUsedViewPagerPage
|
||||
val tabToOpen = intent.getIntExtra(OPEN_TAB, config.lastUsedViewPagerPage)
|
||||
intent.removeExtra(OPEN_TAB)
|
||||
viewpager.currentItem = tabToOpen
|
||||
viewpager.offscreenPageLimit = TABS_COUNT - 1
|
||||
main_tabs_holder.onTabSelectionChanged(
|
||||
tabUnselectedAction = {
|
||||
@ -115,20 +118,19 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
)
|
||||
|
||||
setupTabColors()
|
||||
setupTabColors(tabToOpen)
|
||||
}
|
||||
|
||||
private fun setupTabColors() {
|
||||
val lastUsedPage = config.lastUsedViewPagerPage
|
||||
private fun setupTabColors(lastUsedTab: Int) {
|
||||
main_tabs_holder.apply {
|
||||
background = ColorDrawable(config.backgroundColor)
|
||||
setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
|
||||
getTabAt(lastUsedPage)?.apply {
|
||||
getTabAt(lastUsedTab)?.apply {
|
||||
select()
|
||||
icon?.applyColorFilter(getAdjustedPrimaryColor())
|
||||
}
|
||||
|
||||
getInactiveTabIndexes(lastUsedPage).forEach {
|
||||
getInactiveTabIndexes(lastUsedTab).forEach {
|
||||
getTabAt(it)?.icon?.applyColorFilter(config.textColor)
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,21 @@
|
||||
package com.simplemobiletools.clock.activities
|
||||
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.clock.helpers.OPEN_TAB
|
||||
import com.simplemobiletools.clock.helpers.TAB_ALARM
|
||||
import com.simplemobiletools.commons.activities.BaseSplashActivity
|
||||
|
||||
class SplashActivity : BaseSplashActivity() {
|
||||
override fun initActivity() {
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
when {
|
||||
intent?.action == "android.intent.action.SHOW_ALARMS" -> {
|
||||
Intent(this, MainActivity::class.java).apply {
|
||||
putExtra(OPEN_TAB, TAB_ALARM)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
else -> startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
|
||||
const val OPEN_APP_INTENT_ID = 9998
|
||||
const val TIMER_NOTIF_ID = 9999
|
||||
|
||||
const val OPEN_TAB = "open_tab"
|
||||
const val TAB_ALARM = 1
|
||||
|
||||
const val SORT_BY_LAP = 1
|
||||
const val SORT_BY_LAP_TIME = 2
|
||||
const val SORT_BY_TOTAL_TIME = 4
|
||||
|
Loading…
x
Reference in New Issue
Block a user