From c2d19cf58a9a5a86234fa186c0257d0af37c8881 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 14 May 2018 23:11:20 +0200 Subject: [PATCH] fix clicking on widget days --- app/build.gradle | 2 +- .../calendar/helpers/MyWidgetListProvider.kt | 10 +++------- .../calendar/helpers/MyWidgetMonthlyProvider.kt | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dd3b75d15..ed4b6e2e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:4.0.3' + implementation 'com.simplemobiletools:commons:4.0.13' implementation 'joda-time:joda-time:2.9.9' implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.android.support:multidex:1.0.3' diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt index fec9e3a0b..ee2f21a88 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt @@ -9,14 +9,10 @@ import android.content.Intent import android.net.Uri import android.widget.RemoteViews import com.simplemobiletools.calendar.R -import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.launchNewEventIntent import com.simplemobiletools.calendar.services.WidgetService -import com.simplemobiletools.commons.extensions.getColoredBitmap -import com.simplemobiletools.commons.extensions.setBackgroundColor -import com.simplemobiletools.commons.extensions.setText -import com.simplemobiletools.commons.extensions.setTextSize +import com.simplemobiletools.commons.extensions.* import org.joda.time.DateTime class MyWidgetListProvider : AppWidgetProvider() { @@ -54,7 +50,7 @@ class MyWidgetListProvider : AppWidgetProvider() { views.setRemoteAdapter(R.id.widget_event_list, this) } - val startActivityIntent = Intent(context, SplashActivity::class.java) + val startActivityIntent = context.getLaunchIntent() val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT) views.setPendingIntentTemplate(R.id.widget_event_list, startActivityPendingIntent) views.setEmptyView(R.id.widget_event_list, R.id.widget_event_list_empty) @@ -83,7 +79,7 @@ class MyWidgetListProvider : AppWidgetProvider() { } private fun launchDayActivity(context: Context) { - Intent(context, SplashActivity::class.java).apply { + context.getLaunchIntent().apply { putExtra(DAY_CODE, Formatter.getDayCodeFromDateTime(DateTime())) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt index 4e8ae0f6e..05529164d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt @@ -10,7 +10,6 @@ import android.content.res.Resources import android.view.View import android.widget.RemoteViews import com.simplemobiletools.calendar.R -import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.launchNewEventIntent import com.simplemobiletools.calendar.interfaces.MonthlyCalendar @@ -46,7 +45,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { } private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) { - Intent(context, SplashActivity::class.java).apply { + context.getLaunchIntent().apply { putExtra(DAY_CODE, dayCode) putExtra(OPEN_MONTH, true) val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode.substring(0, 6)), this, 0) @@ -55,7 +54,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { } private fun setupDayOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) { - Intent(context, SplashActivity::class.java).apply { + context.getLaunchIntent().apply { putExtra(DAY_CODE, dayCode) val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode), this, 0) views.setOnClickPendingIntent(id, pendingIntent)