mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-31 10:54:51 +01:00
use proper time and date at new tasks
This commit is contained in:
parent
b6d21c1b4a
commit
fc66698acf
@ -113,10 +113,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
}
|
||||
|
||||
fab_task_icon.setOnClickListener {
|
||||
hideKeyboard()
|
||||
Intent(this, TaskActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
openNewTask()
|
||||
|
||||
Handler().postDelayed({
|
||||
hideExtendedFab()
|
||||
@ -930,6 +927,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
launchNewEventIntent(lastFragment.getNewEventDayCode(), allowChangingDay)
|
||||
}
|
||||
|
||||
private fun openNewTask() {
|
||||
hideKeyboard()
|
||||
val lastFragment = currentFragments.last()
|
||||
val allowChangingDay = lastFragment !is DayFragmentsHolder && lastFragment !is MonthDayFragmentsHolder
|
||||
launchNewTaskIntent(lastFragment.getNewEventDayCode(), allowChangingDay)
|
||||
}
|
||||
|
||||
fun openMonthFromYearly(dateTime: DateTime) {
|
||||
if (currentFragments.last() is MonthFragmentsHolder) {
|
||||
return
|
||||
|
@ -8,6 +8,7 @@ import android.view.WindowManager
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.helpers.NEW_EVENT_START_TS
|
||||
import com.simplemobiletools.calendar.pro.helpers.TASK_ID
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import kotlinx.android.synthetic.main.activity_task.*
|
||||
@ -29,7 +30,6 @@ class TaskActivity : SimpleActivity() {
|
||||
val intent = intent ?: return
|
||||
mDialogTheme = getDialogTheme()
|
||||
val taskId = intent.getLongExtra(TASK_ID, 0L)
|
||||
mTaskDateTime = DateTime.now()
|
||||
updateColors()
|
||||
gotTask()
|
||||
}
|
||||
@ -54,6 +54,10 @@ class TaskActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun setupNewTask() {
|
||||
val startTS = intent.getLongExtra(NEW_EVENT_START_TS, 0L)
|
||||
val dateTime = Formatter.getDateTimeFromTS(startTS)
|
||||
mTaskDateTime = dateTime
|
||||
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
task_title.requestFocus()
|
||||
updateActionBarTitle(getString(R.string.new_task))
|
||||
|
@ -27,6 +27,7 @@ import androidx.print.PrintHelper
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.SnoozeReminderActivity
|
||||
import com.simplemobiletools.calendar.pro.activities.TaskActivity
|
||||
import com.simplemobiletools.calendar.pro.databases.EventsDatabase
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
@ -368,6 +369,15 @@ fun Context.launchNewEventIntent(dayCode: String = Formatter.getTodayCode(), all
|
||||
}
|
||||
}
|
||||
|
||||
// if the default start time is set to "Next full hour" and the task is created before midnight, it could change the day
|
||||
fun Context.launchNewTaskIntent(dayCode: String = Formatter.getTodayCode(), allowChangingDay: Boolean = false) {
|
||||
Intent(applicationContext, TaskActivity::class.java).apply {
|
||||
putExtra(NEW_EVENT_START_TS, getNewEventTimestampFromCode(dayCode, allowChangingDay))
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getNewEventTimestampFromCode(dayCode: String, allowChangingDay: Boolean = false): Long {
|
||||
val calendar = Calendar.getInstance()
|
||||
val defaultStartTime = config.defaultStartTime
|
||||
|
Loading…
x
Reference in New Issue
Block a user