mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-30 02:30:38 +00:00
Support due date for todos. Fixes
This commit is contained in:
parent
1ebff30bbe
commit
999ddd053d
6 changed files with 56 additions and 8 deletions
1
Habitica/assets/migrations/Habitica/9.sql
Normal file
1
Habitica/assets/migrations/Habitica/9.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE Task ADD COLUMN 'duedate' DATE;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
|
@ -248,7 +249,33 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false"
|
||||
android:datePickerMode="spinner" />
|
||||
android:datePickerMode="spinner"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/task_duedate_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="140dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/due_date"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<DatePicker
|
||||
android:id="@+id/task_duedate_picker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:calendarViewShown="false"
|
||||
android:datePickerMode="spinner"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -265,6 +292,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableRight="@drawable/ic_action_delete_white_24"
|
||||
android:drawableEnd="@drawable/ic_action_delete_white_24"
|
||||
android:text="@string/action_delete"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
|
|
|
|||
|
|
@ -160,4 +160,5 @@
|
|||
<string name="purchase_set_button" formatted="false">Unlock set for %d gems</string>
|
||||
<string name="purchase_button">Purchase</string>
|
||||
<string name="purchase_set_title" formatted="false">Purchase set %s</string>
|
||||
<string name="due_date">Due Date</string>
|
||||
</resources>
|
||||
|
|
@ -10,5 +10,5 @@ public class HabitDatabase {
|
|||
|
||||
public static final String NAME = "Habitica";
|
||||
|
||||
public static final int VERSION = 8;
|
||||
public static final int VERSION = 9;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,12 @@ public class TaskFormActivity extends BaseActivity implements AdapterView.OnItem
|
|||
@Bind(R.id.add_checklist_button)
|
||||
Button button;
|
||||
|
||||
@Bind(R.id.task_duedate_layout)
|
||||
LinearLayout dueDateLayout;
|
||||
|
||||
@Bind(R.id.task_duedate_picker)
|
||||
DatePicker dueDatePicker;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_task_form;
|
||||
|
|
@ -199,6 +205,10 @@ public class TaskFormActivity extends BaseActivity implements AdapterView.OnItem
|
|||
mainWrapper.removeView(startDateLayout);
|
||||
}
|
||||
|
||||
if (!taskType.equals("todo")) {
|
||||
mainWrapper.removeView(dueDateLayout);
|
||||
}
|
||||
|
||||
if (!taskType.equals("reward")) {
|
||||
taskValueLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
|
@ -397,6 +407,12 @@ public class TaskFormActivity extends BaseActivity implements AdapterView.OnItem
|
|||
}
|
||||
}
|
||||
|
||||
if (task.type.equals("todo")) {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(task.getDueDate());
|
||||
dueDatePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean saveTask(Task task) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.magicmicky.habitrpgwrapper.lib.models.tasks;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.habitrpg.android.habitica.HabitDatabase;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.raizlabs.android.dbflow.annotation.Column;
|
||||
|
|
@ -92,7 +93,8 @@ public class Task extends BaseModel {
|
|||
|
||||
//todos
|
||||
@Column
|
||||
public String date;
|
||||
@SerializedName("date")
|
||||
public Date duedate;
|
||||
|
||||
// used for buyable items
|
||||
public String specialTag;
|
||||
|
|
@ -326,16 +328,16 @@ public class Task extends BaseModel {
|
|||
/**
|
||||
* @return the due date
|
||||
*/
|
||||
public String getDate() {
|
||||
return date;
|
||||
public Date getDueDate() {
|
||||
return this.duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the due date
|
||||
* @param date the date to set
|
||||
* @param duedate the date to set
|
||||
*/
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
public void setDueDate(Date duedate) {
|
||||
this.duedate = duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue