Merge pull request #1753 from Naveen3Singh/event_type_picker
Allow creating tasks as well using the event list widget btn
This commit is contained in:
commit
c66d5ad2f4
5 changed files with 56 additions and 4 deletions
|
@ -194,6 +194,11 @@
|
|||
android:exported="false"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.EventTypePickerActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
<receiver
|
||||
android:name=".helpers.MyWidgetMonthlyProvider"
|
||||
android:exported="true"
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.simplemobiletools.calendar.pro.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewTaskIntent
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
|
||||
class EventTypePickerActivity : AppCompatActivity() {
|
||||
private val TYPE_EVENT = 0
|
||||
private val TYPE_TASK = 1
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val items = arrayListOf(
|
||||
RadioItem(TYPE_EVENT, getString(R.string.event)),
|
||||
RadioItem(TYPE_TASK, getString(R.string.task))
|
||||
)
|
||||
RadioGroupDialog(this, items = items, cancelCallback = { dialogCancelled() }) {
|
||||
val checkedId = it as Int
|
||||
if (checkedId == TYPE_EVENT) {
|
||||
launchNewEventIntent()
|
||||
} else if (checkedId == TYPE_TASK) {
|
||||
launchNewTaskIntent()
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogCancelled() {
|
||||
finish()
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import androidx.core.app.NotificationCompat
|
|||
import androidx.print.PrintHelper
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.EventTypePickerActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.SnoozeReminderActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.TaskActivity
|
||||
import com.simplemobiletools.calendar.pro.databases.EventsDatabase
|
||||
|
@ -376,6 +377,17 @@ fun Context.launchNewTaskIntent(dayCode: String = Formatter.getTodayCode(), allo
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.launchNewEventOrTaskActivity() {
|
||||
if (config.allowCreatingTasks) {
|
||||
Intent(this, EventTypePickerActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(this)
|
||||
}
|
||||
} else {
|
||||
launchNewEventIntent()
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getNewEventTimestampFromCode(dayCode: String, allowChangingDay: Boolean = false): Long {
|
||||
val calendar = Calendar.getInstance()
|
||||
val defaultStartTime = config.defaultStartTime
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.simplemobiletools.calendar.pro.R
|
|||
import com.simplemobiletools.calendar.pro.activities.SplashActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewEventOrTaskActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.widgetsDB
|
||||
import com.simplemobiletools.calendar.pro.services.WidgetService
|
||||
import com.simplemobiletools.calendar.pro.services.WidgetServiceEmpty
|
||||
|
@ -86,7 +86,7 @@ class MyWidgetListProvider : AppWidgetProvider() {
|
|||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.action) {
|
||||
NEW_EVENT -> context.launchNewEventIntent()
|
||||
NEW_EVENT -> context.launchNewEventOrTaskActivity()
|
||||
LAUNCH_CAL -> launchCalenderInDefaultView(context)
|
||||
GO_TO_TODAY -> goToToday(context)
|
||||
else -> super.onReceive(context, intent)
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.simplemobiletools.calendar.pro.R
|
|||
import com.simplemobiletools.calendar.pro.activities.SplashActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
|
||||
import com.simplemobiletools.calendar.pro.extensions.launchNewEventOrTaskActivity
|
||||
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
|
||||
import com.simplemobiletools.calendar.pro.models.DayMonthly
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
|
@ -73,7 +73,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
|
|||
PREV -> getPrevMonth(context)
|
||||
NEXT -> getNextMonth(context)
|
||||
GO_TO_TODAY -> goToToday(context)
|
||||
NEW_EVENT -> context.launchNewEventIntent()
|
||||
NEW_EVENT -> context.launchNewEventOrTaskActivity()
|
||||
else -> super.onReceive(context, intent)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue