send widget clicks through the Splash activity to avoid flashing white screen

This commit is contained in:
tibbi 2017-01-24 22:14:30 +01:00
parent b14ff9ccee
commit c217e24b76
3 changed files with 21 additions and 7 deletions

View File

@ -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()
}
}

View File

@ -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)

View File

@ -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)