Changes after review

This commit is contained in:
MohitMaliDeveloper 2022-11-18 14:34:40 +05:30
parent 9dc2c48df6
commit 91031b07b0
4 changed files with 19 additions and 7 deletions

View File

@ -18,8 +18,13 @@ import androidx.lifecycle.ProcessLifecycleOwner
import com.facebook.stetho.Stetho import com.facebook.stetho.Stetho
import com.simplemobiletools.clock.activities.SplashActivity import com.simplemobiletools.clock.activities.SplashActivity
import com.simplemobiletools.clock.extensions.* 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.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.TimerEvent
import com.simplemobiletools.clock.models.TimerState import com.simplemobiletools.clock.models.TimerState
import com.simplemobiletools.clock.services.StopwatchStopService 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.clock.services.startTimerService
import com.simplemobiletools.commons.extensions.checkUseEnglish import com.simplemobiletools.commons.extensions.checkUseEnglish
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.helpers.isNougatMR1Plus
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode import org.greenrobot.eventbus.ThreadMode
@ -46,16 +52,16 @@ class App : Application(), LifecycleObserver {
} }
checkUseEnglish() checkUseEnglish()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { if (isNougatMR1Plus()) {
val shortcutManager = getSystemService(ShortcutManager::class.java) val shortcutManager = getSystemService(ShortcutManager::class.java)
val intent = Intent(this, SplashActivity::class.java).apply { val intent = Intent(this, SplashActivity::class.java).apply {
putExtra(OPEN_TAB, TAB_STOPWATCH) putExtra(OPEN_TAB, TAB_STOPWATCH)
putExtra(TOGGLE_STOPWATCH, true) putExtra(TOGGLE_STOPWATCH, true)
action = "android.intent.action.TOGGLE_STOPWATCH" action = STOPWATCH_TOGGLE_ACTION
} }
val shortcut = ShortcutInfo.Builder(this, "id1") val shortcut = ShortcutInfo.Builder(this, STOPWATCH_SHORTCUT_ID)
.setShortLabel("Stopwatch") .setShortLabel(getString(R.string.stopwatch))
.setLongLabel("Start Stopwatch") .setLongLabel(getString(R.string.start_stopwatch))
.setIcon(Icon.createWithResource(this, R.drawable.ic_stopwatch_vector)) .setIcon(Icon.createWithResource(this, R.drawable.ic_stopwatch_vector))
.setIntent( .setIntent(
intent intent

View File

@ -13,7 +13,7 @@ class SplashActivity : BaseSplashActivity() {
startActivity(this) startActivity(this)
} }
} }
intent?.action == "android.intent.action.TOGGLE_STOPWATCH" -> { intent?.action == STOPWATCH_TOGGLE_ACTION -> {
Intent(this, MainActivity::class.java).apply { Intent(this, MainActivity::class.java).apply {
putExtra(OPEN_TAB, TAB_STOPWATCH) putExtra(OPEN_TAB, TAB_STOPWATCH)
putExtra(TOGGLE_STOPWATCH, intent.getBooleanExtra(TOGGLE_STOPWATCH, false)) putExtra(TOGGLE_STOPWATCH, intent.getBooleanExtra(TOGGLE_STOPWATCH, false))

View File

@ -61,6 +61,10 @@ const val SORT_BY_DATE_AND_TIME = 2
const val TODAY_BIT = -1 const val TODAY_BIT = -1
const val TOMORROW_BIT = -2 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 getDefaultTimeZoneTitle(id: Int) = getAllTimeZones().firstOrNull { it.id == id }?.title ?: ""
fun getPassedSeconds(): Int { fun getPassedSeconds(): Int {

View File

@ -53,4 +53,6 @@
Haven't found some strings? There's more at Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
--> -->
<string name="start_stopwatch">Start Stopwatch</string>
</resources> </resources>