diff --git a/Habitica/res/layout/daily_item_card.xml b/Habitica/res/layout/daily_item_card.xml
index 74e712366..b6e386fe0 100644
--- a/Habitica/res/layout/daily_item_card.xml
+++ b/Habitica/res/layout/daily_item_card.xml
@@ -26,7 +26,7 @@
android:layout_width="@dimen/button_width"
android:layout_height="match_parent"
android:checked="@{daily.completed}"
- app:backgroundColor="@{daily.getLightTaskColor}"
+ app:backgroundColor="@{daily.isDue ? daily.getLightTaskColor : @color/task_gray}"
android:gravity="center"
android:layout_gravity="center_horizontal" />
+ android:text="@{todo.notes}"
+ android:visibility="@{todo.notes != null ? View.VISIBLE : View.GONE}" />
#c3c2c6
#ededed
+ #b5b5b5
\ No newline at end of file
diff --git a/Habitica/src/com/habitrpg/android/habitica/OnTasksChanged.java b/Habitica/src/com/habitrpg/android/habitica/OnTasksChanged.java
deleted file mode 100644
index d27f3e58b..000000000
--- a/Habitica/src/com/habitrpg/android/habitica/OnTasksChanged.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.habitrpg.android.habitica;
-
-import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
-
-import java.util.List;
-
-
-public interface OnTasksChanged {
- void onChange(List tasks);
- void onTagFilter(List tags);
-
-}
diff --git a/Habitica/src/com/habitrpg/android/habitica/ui/adapter/HabitItemRecyclerViewAdapter.java b/Habitica/src/com/habitrpg/android/habitica/ui/adapter/HabitItemRecyclerViewAdapter.java
index c98587688..e8ac1b634 100644
--- a/Habitica/src/com/habitrpg/android/habitica/ui/adapter/HabitItemRecyclerViewAdapter.java
+++ b/Habitica/src/com/habitrpg/android/habitica/ui/adapter/HabitItemRecyclerViewAdapter.java
@@ -28,6 +28,7 @@ import com.habitrpg.android.habitica.databinding.TodoItemCardBinding;
import com.habitrpg.android.habitica.events.BuyRewardTappedEvent;
import com.habitrpg.android.habitica.events.HabitScoreEvent;
import com.habitrpg.android.habitica.events.TaskLongPressedEvent;
+import com.habitrpg.android.habitica.events.TaskSaveEvent;
import com.habitrpg.android.habitica.events.TaskTappedEvent;
import com.habitrpg.android.habitica.events.TaskCheckedEvent;
import com.habitrpg.android.habitica.ui.helpers.ViewHelper;
@@ -208,27 +209,42 @@ public class HabitItemRecyclerViewAdapter
@BindingAdapter("bind:cardColor")
public static void setCardColor(CardView cardView, int color) {
- cardView.setCardBackgroundColor(cardView.getResources().getColor(color));
+ if (color > 0) {
+ color = cardView.getResources().getColor(color);
+ }
+ cardView.setCardBackgroundColor(color);
}
@BindingAdapter("app:backgroundColor")
public static void setBackgroundTintColor(CheckBox view, int color) {
- ViewHelper.SetBackgroundTint(view, view.getResources().getColor(color));
+ if (color > 0) {
+ color = view.getResources().getColor(color);
+ }
+ ViewHelper.SetBackgroundTint(view, color);
}
@BindingAdapter("app:backgroundColor")
public static void setBackgroundTintColor(Button view, int color) {
- ViewHelper.SetBackgroundTint(view, view.getResources().getColor(color));
+ if (color > 0) {
+ color = view.getResources().getColor(color);
+ }
+ ViewHelper.SetBackgroundTint(view, color);
}
@BindingAdapter("app:backgroundColor")
public static void setBackgroundTintColor(View view, int color) {
- view.setBackgroundColor(view.getResources().getColor(color));
+ if (color > 0) {
+ color = view.getResources().getColor(color);
+ }
+ view.setBackgroundColor(color);
}
@BindingAdapter("app:foregroundColor")
public static void setForegroundTintColor(TextView view, int color) {
- view.setTextColor(view.getResources().getColor(color));
+ if (color > 0) {
+ color = view.getResources().getColor(color);
+ }
+ view.setTextColor(color);
}
@Override
@@ -331,7 +347,10 @@ public class HabitItemRecyclerViewAdapter
}
}
- public class ChecklistedViewHolder extends ViewHolder {
+ public class ChecklistedViewHolder extends ViewHolder implements CompoundButton.OnCheckedChangeListener {
+
+ @InjectView(R.id.checkBox)
+ CheckBox checkbox;
@InjectView(R.id.checklistView)
LinearLayout checklistView;
@@ -344,6 +363,7 @@ public class HabitItemRecyclerViewAdapter
public ChecklistedViewHolder(View itemView) {
super(itemView);
checklistIndicatorWrapper.setOnClickListener(this);
+ checkbox.setOnCheckedChangeListener(this);
}
@Override
@@ -373,12 +393,14 @@ public class HabitItemRecyclerViewAdapter
public void setDisplayChecklist(Boolean displayChecklist) {
this.displayChecklist = displayChecklist;
+ //This needs to be a LinearLayout, as ListViews can not be inside other ListViews.
if (this.checklistView != null) {
if (this.displayChecklist && this.Item.checklist != null) {
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (ChecklistItem item : this.Item.checklist) {
LinearLayout itemView = (LinearLayout)layoutInflater.inflate(R.layout.checklist_item_row, null);
CheckBox checkbox = (CheckBox) itemView.findViewById(R.id.checkBox);
+ checkbox.setOnCheckedChangeListener(this);
TextView textView = (TextView) itemView.findViewById(R.id.checkedTextView);
// Populate the data into the template view using the data object
textView.setText(item.getText());
@@ -390,11 +412,28 @@ public class HabitItemRecyclerViewAdapter
}
}
}
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (buttonView == checkbox) {
+ if (isChecked != Item.getCompleted()) {
+ TaskCheckedEvent event = new TaskCheckedEvent();
+ event.Task = Item;
+ EventBus.getDefault().post(event);
+ }
+ } else {
+ Integer position = (Integer) ((ViewGroup)checkbox.getParent().getParent()).indexOfChild((View)checkbox.getParent());
+ if (isChecked != Item.checklist.get(position).getCompleted()) {
+ TaskSaveEvent event = new TaskSaveEvent();
+ Item.checklist.get(position).setCompleted(isChecked);
+ event.task = Item;
+ EventBus.getDefault().post(event);
+ }
+ }
+ }
}
- public class DailyViewHolder extends ChecklistedViewHolder implements CompoundButton.OnCheckedChangeListener {
- @InjectView(R.id.checkBox)
- CheckBox checkbox;
+ public class DailyViewHolder extends ChecklistedViewHolder {
DailyItemCardBinding binding;
@@ -420,21 +459,9 @@ public class HabitItemRecyclerViewAdapter
super.setDisplayChecklist(displayChecklist);
}
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked != Item.getCompleted()) {
- TaskCheckedEvent event = new TaskCheckedEvent();
- event.Task = Item;
- EventBus.getDefault().post(event);
- }
- }
-
}
- public class TodoViewHolder extends ChecklistedViewHolder implements CompoundButton.OnCheckedChangeListener {
-
- @InjectView(R.id.checkBox)
- CheckBox checkbox;
+ public class TodoViewHolder extends ChecklistedViewHolder {
TodoItemCardBinding binding;
@@ -442,8 +469,6 @@ public class HabitItemRecyclerViewAdapter
super(itemView);
binding = DataBindingUtil.bind(itemView);
-
- checkbox.setOnCheckedChangeListener(this);
}
@Override
@@ -453,15 +478,6 @@ public class HabitItemRecyclerViewAdapter
binding.setTodo(habitItem);
}
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked != Item.getCompleted()) {
- TaskCheckedEvent event = new TaskCheckedEvent();
- event.Task = Item;
- EventBus.getDefault().post(event);
- }
- }
-
@Override
public void setDisplayChecklist(Boolean displayChecklist) {
binding.setDisplayChecklist(displayChecklist);
diff --git a/Habitica/src/com/magicmicky/habitrpgwrapper/lib/models/tasks/Task.java b/Habitica/src/com/magicmicky/habitrpgwrapper/lib/models/tasks/Task.java
index e1eca1317..798087b19 100644
--- a/Habitica/src/com/magicmicky/habitrpgwrapper/lib/models/tasks/Task.java
+++ b/Habitica/src/com/magicmicky/habitrpgwrapper/lib/models/tasks/Task.java
@@ -369,4 +369,9 @@ public class Task extends BaseModel {
return R.color.best_10;
}
+
+ public Boolean isDue() {
+ //TODO: check if daily is due
+ return !this.getCompleted();
+ }
}