mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2024-12-12 16:26:35 +01:00
Changes after review
This commit is contained in:
parent
9dc2c48df6
commit
91031b07b0
@ -18,8 +18,13 @@ import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import com.facebook.stetho.Stetho
|
||||
import com.simplemobiletools.clock.activities.SplashActivity
|
||||
import com.simplemobiletools.clock.extensions.*
|
||||
import com.simplemobiletools.clock.helpers.*
|
||||
import com.simplemobiletools.clock.helpers.OPEN_TAB
|
||||
import com.simplemobiletools.clock.helpers.Stopwatch
|
||||
import com.simplemobiletools.clock.helpers.Stopwatch.State
|
||||
import com.simplemobiletools.clock.helpers.TAB_STOPWATCH
|
||||
import com.simplemobiletools.clock.helpers.TOGGLE_STOPWATCH
|
||||
import com.simplemobiletools.clock.helpers.STOPWATCH_TOGGLE_ACTION
|
||||
import com.simplemobiletools.clock.helpers.STOPWATCH_SHORTCUT_ID
|
||||
import com.simplemobiletools.clock.models.TimerEvent
|
||||
import com.simplemobiletools.clock.models.TimerState
|
||||
import com.simplemobiletools.clock.services.StopwatchStopService
|
||||
@ -28,6 +33,7 @@ import com.simplemobiletools.clock.services.startStopwatchService
|
||||
import com.simplemobiletools.clock.services.startTimerService
|
||||
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.commons.helpers.isNougatMR1Plus
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@ -46,16 +52,16 @@ class App : Application(), LifecycleObserver {
|
||||
}
|
||||
|
||||
checkUseEnglish()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
if (isNougatMR1Plus()) {
|
||||
val shortcutManager = getSystemService(ShortcutManager::class.java)
|
||||
val intent = Intent(this, SplashActivity::class.java).apply {
|
||||
putExtra(OPEN_TAB, TAB_STOPWATCH)
|
||||
putExtra(TOGGLE_STOPWATCH, true)
|
||||
action = "android.intent.action.TOGGLE_STOPWATCH"
|
||||
action = STOPWATCH_TOGGLE_ACTION
|
||||
}
|
||||
val shortcut = ShortcutInfo.Builder(this, "id1")
|
||||
.setShortLabel("Stopwatch")
|
||||
.setLongLabel("Start Stopwatch")
|
||||
val shortcut = ShortcutInfo.Builder(this, STOPWATCH_SHORTCUT_ID)
|
||||
.setShortLabel(getString(R.string.stopwatch))
|
||||
.setLongLabel(getString(R.string.start_stopwatch))
|
||||
.setIcon(Icon.createWithResource(this, R.drawable.ic_stopwatch_vector))
|
||||
.setIntent(
|
||||
intent
|
||||
|
@ -13,7 +13,7 @@ class SplashActivity : BaseSplashActivity() {
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
intent?.action == "android.intent.action.TOGGLE_STOPWATCH" -> {
|
||||
intent?.action == STOPWATCH_TOGGLE_ACTION -> {
|
||||
Intent(this, MainActivity::class.java).apply {
|
||||
putExtra(OPEN_TAB, TAB_STOPWATCH)
|
||||
putExtra(TOGGLE_STOPWATCH, intent.getBooleanExtra(TOGGLE_STOPWATCH, false))
|
||||
|
@ -61,6 +61,10 @@ const val SORT_BY_DATE_AND_TIME = 2
|
||||
const val TODAY_BIT = -1
|
||||
const val TOMORROW_BIT = -2
|
||||
|
||||
// stopwatch shortcut
|
||||
const val STOPWATCH_SHORTCUT_ID = "stopwatch_shortcut_id"
|
||||
const val STOPWATCH_TOGGLE_ACTION = "android.intent.action.TOGGLE_STOPWATCH"
|
||||
|
||||
fun getDefaultTimeZoneTitle(id: Int) = getAllTimeZones().firstOrNull { it.id == id }?.title ?: ""
|
||||
|
||||
fun getPassedSeconds(): Int {
|
||||
|
@ -53,4 +53,6 @@
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
-->
|
||||
|
||||
<string name="start_stopwatch">Start Stopwatch</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user