From c217e24b76c8133693e78f438d3782bb987b284c Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 24 Jan 2017 22:14:30 +0100 Subject: [PATCH] send widget clicks through the Splash activity to avoid flashing white screen --- .../calendar/activities/SplashActivity.kt | 17 ++++++++++++++++- .../calendar/helpers/MyWidgetListProvider.kt | 4 ++-- .../calendar/helpers/MyWidgetMonthlyProvider.kt | 7 +++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt index 1b178501d..9b531a20b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt @@ -3,11 +3,26 @@ package com.simplemobiletools.calendar.activities import android.content.Intent import android.os.Bundle import android.support.v7.app.AppCompatActivity +import com.simplemobiletools.calendar.helpers.DAY_CODE +import com.simplemobiletools.calendar.helpers.EVENT_ID class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - startActivity(Intent(this, MainActivity::class.java)) + + if (intent.extras?.containsKey(DAY_CODE) == true) { + Intent(this, DayActivity::class.java).apply { + putExtra(DAY_CODE, intent.getStringExtra(DAY_CODE)) + startActivity(this) + } + } else if (intent.extras?.containsKey(EVENT_ID) == true) { + Intent(this, EventActivity::class.java).apply { + putExtra(EVENT_ID, intent.getIntExtra(EVENT_ID, 0)) + startActivity(this) + } + } else { + startActivity(Intent(this, MainActivity::class.java)) + } finish() } } 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 9c4d18f0f..3f5146657 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt @@ -10,7 +10,7 @@ import android.content.res.Resources import android.net.Uri import android.widget.RemoteViews import com.simplemobiletools.calendar.R -import com.simplemobiletools.calendar.activities.EventActivity +import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.services.WidgetService @@ -47,7 +47,7 @@ class MyWidgetListProvider : AppWidgetProvider() { mRemoteViews.setRemoteAdapter(R.id.widget_event_list, this) } - val startActivityIntent = Intent(context, EventActivity::class.java) + val startActivityIntent = Intent(context, SplashActivity::class.java) val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT) mRemoteViews.setPendingIntentTemplate(R.id.widget_event_list, startActivityPendingIntent) mRemoteViews.setEmptyView(R.id.widget_event_list, R.id.widget_event_list_empty) 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 f1fe63d21..6a2608484 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt @@ -14,8 +14,7 @@ import android.text.style.UnderlineSpan import android.view.View import android.widget.RemoteViews import com.simplemobiletools.calendar.R -import com.simplemobiletools.calendar.activities.DayActivity -import com.simplemobiletools.calendar.activities.MainActivity +import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.interfaces.MonthlyCalendar import com.simplemobiletools.calendar.models.Day @@ -78,14 +77,14 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar { } private fun setupAppOpenIntent(id: Int) { - Intent(mContext, MainActivity::class.java).apply { + Intent(mContext, SplashActivity::class.java).apply { val pendingIntent = PendingIntent.getActivity(mContext, 0, this, 0) mRemoteViews.setOnClickPendingIntent(id, pendingIntent) } } private fun setupDayOpenIntent(id: Int, dayCode: String) { - Intent(mContext, DayActivity::class.java).apply { + Intent(mContext, SplashActivity::class.java).apply { putExtra(DAY_CODE, dayCode) val pendingIntent = PendingIntent.getActivity(mContext, Integer.parseInt(dayCode), this, 0) mRemoteViews.setOnClickPendingIntent(id, pendingIntent)