|
|
@@ -98,11 +98,7 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
|
|
|
|
|
|
clockTextView.setOnClickListener {
|
|
|
try {
|
|
|
- val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
- Intent(AlarmClock.ACTION_SHOW_ALARMS)
|
|
|
- } else {
|
|
|
- alternativeClockIntent()
|
|
|
- }
|
|
|
+ val intent = alternativeClockIntent()
|
|
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
val left = 0
|
|
|
val top = 0
|
|
|
@@ -243,7 +239,7 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
|
|
|
|
|
|
private fun alternativeClockIntent(): Intent {
|
|
|
val alarmClockIntent = Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
|
|
|
-
|
|
|
+ val pm = activity!!.packageManager
|
|
|
// Verify clock implementation
|
|
|
val clockImpls = arrayOf(arrayOf("HTC Alarm Clock", "com.htc.android.worldclock", "com.htc.android.worldclock.WorldClockTabControl"), arrayOf("Standar Alarm Clock", "com.android.deskclock", "com.android.deskclock.AlarmClock"), arrayOf("Froyo Nexus Alarm Clock", "com.google.android.deskclock", "com.android.deskclock.DeskClock"), arrayOf("Moto Blur Alarm Clock", "com.motorola.blur.alarmclock", "com.motorola.blur.alarmclock.AlarmClock"), arrayOf("Samsung Galaxy Clock", "com.sec.android.app.clockpackage", "com.sec.android.app.clockpackage.ClockPackage"), arrayOf("Sony Ericsson Xperia Z", "com.sonyericsson.organizer", "com.sonyericsson.organizer.Organizer_WorldClock"), arrayOf("ASUS Tablets", "com.asus.deskclock", "com.asus.deskclock.DeskClock"))
|
|
|
|
|
|
@@ -254,16 +250,25 @@ class MainFragment : StatusBarThemeFragment(), MainActivity.OnBackPressedListene
|
|
|
val className = clockImpls[i][2]
|
|
|
val cn = ComponentName(packageName, className)
|
|
|
alarmClockIntent.component = cn
|
|
|
- foundClockImpl = true
|
|
|
+ if (alarmClockIntent.resolveActivity(pm) != null)
|
|
|
+ foundClockImpl = true
|
|
|
}
|
|
|
|
|
|
if (!foundClockImpl) {
|
|
|
throw Exception()
|
|
|
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
+ val i = Intent(AlarmClock.ACTION_SHOW_ALARMS)
|
|
|
+ if (alarmClockIntent.resolveActivity(pm) != null) {
|
|
|
+ return i
|
|
|
+ } else {
|
|
|
+ throw Exception("No clock activity found for the intent")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw Exception("No clock activity found for the intent")
|
|
|
}
|
|
|
- return alarmClockIntent
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private fun doBounceAnimation(targetView: View) {
|
|
|
targetView.animate()
|
|
|
.setStartDelay(500)
|