open the app after clicking on the widget

This commit is contained in:
tibbi 2018-03-12 16:46:12 +01:00
parent c1feb66b91
commit f399a3506a
2 changed files with 14 additions and 1 deletions

View file

@ -20,10 +20,12 @@ const val EDITED_TIME_ZONE_SEPARATOR = ":"
const val ALARM_ID = "alarm_id" const val ALARM_ID = "alarm_id"
const val DEFAULT_ALARM_MINUTES = 480 const val DEFAULT_ALARM_MINUTES = 480
const val DAY_MINUTES = 1440 const val DAY_MINUTES = 1440
const val TIMER_NOTIF_ID = 9999
const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300 const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60 const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
const val OPEN_APP_INTENT_ID = 9998
const val TIMER_NOTIF_ID = 9999
const val SORT_BY_LAP = 1 const val SORT_BY_LAP = 1
const val SORT_BY_LAP_TIME = 2 const val SORT_BY_LAP_TIME = 2
const val SORT_BY_TOTAL_TIME = 4 const val SORT_BY_TOTAL_TIME = 4

View file

@ -1,11 +1,14 @@
package com.simplemobiletools.clock.helpers package com.simplemobiletools.clock.helpers
import android.app.PendingIntent
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider import android.appwidget.AppWidgetProvider
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent
import android.widget.RemoteViews import android.widget.RemoteViews
import com.simplemobiletools.clock.R import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SplashActivity
import com.simplemobiletools.clock.extensions.config import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.getFormattedDate import com.simplemobiletools.clock.extensions.getFormattedDate
import com.simplemobiletools.clock.extensions.getFormattedTime import com.simplemobiletools.clock.extensions.getFormattedTime
@ -26,6 +29,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
RemoteViews(context.packageName, layout).apply { RemoteViews(context.packageName, layout).apply {
updateTexts(context, this) updateTexts(context, this)
updateColors(context, this) updateColors(context, this)
setupAppOpenIntent(context, this)
appWidgetManager.updateAppWidget(it, this) appWidgetManager.updateAppWidget(it, this)
} }
} }
@ -52,4 +56,11 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
} }
private fun getComponentName(context: Context) = ComponentName(context, this::class.java) private fun getComponentName(context: Context) = ComponentName(context, this::class.java)
private fun setupAppOpenIntent(context: Context, views: RemoteViews) {
Intent(context, SplashActivity::class.java).apply {
val pendingIntent = PendingIntent.getActivity(context, OPEN_APP_INTENT_ID, this, 0)
views.setOnClickPendingIntent(R.id.widget_date_time_holder, pendingIntent)
}
}
} }