Adjust checkboxes in task lists

This commit is contained in:
Phillip Thelen 2015-11-07 19:10:03 +01:00
parent afd23a4ae9
commit e8c12522b7
21 changed files with 136 additions and 26 deletions

View file

@ -145,13 +145,13 @@
<orderEntry type="library" exported="" name="iconics-core-1.7.9" level="project" />
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
<orderEntry type="library" exported="" name="javawriter-2.5.0" level="project" />
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
<orderEntry type="library" exported="" name="fab-1.6.1" level="project" />
<orderEntry type="library" exported="" name="instabugcore-1.8-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="kotlin-runtime-0.12.613" level="project" />
<orderEntry type="library" exported="" name="DBFlow-Compiler-2.2.1" level="project" />
<orderEntry type="library" exported="" name="kotlin-runtime-0.12.613" level="project" />
<orderEntry type="library" exported="" name="answers-1.2.0" level="project" />
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
<orderEntry type="library" exported="" name="retrofit-1.9.0" level="project" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/daily_checked" />
<item android:state_checked="false" android:drawable="@drawable/daily_unchecked" />
</selector>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="@dimen/daily_checkbox_corner_radius"/>
<solid android:color="@color/checkbox_checked_fill" />
<stroke android:color="@color/checkbox_stroke" android:width="1dp" />
<size android:height="@dimen/checkbox_size" android:width="@dimen/checkbox_size" />
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/ic_check" android:gravity="center" />
</item>
</layer-list>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="@dimen/daily_checkbox_corner_radius"/>
<solid android:color="@color/checkbox_fill" />
<stroke android:color="@color/checkbox_stroke" android:width="1dp" />
<size android:height="@dimen/checkbox_size" android:width="@dimen/checkbox_size" />
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/todo_checked" />
<item android:state_checked="false" android:drawable="@drawable/todo_unchecked" />
</selector>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<corners android:radius="@dimen/daily_checkbox_corner_radius"/>
<solid android:color="@color/checkbox_checked_fill" />
<stroke android:color="@color/checkbox_stroke" android:width="1dp" />
<size android:height="@dimen/checkbox_size" android:width="@dimen/checkbox_size" />
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/ic_check" android:gravity="center" />
</item>
</layer-list>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<corners android:radius="@dimen/daily_checkbox_corner_radius"/>
<solid android:color="@color/checkbox_fill" />
<stroke android:color="@color/checkbox_stroke" android:width="1dp" />
<size android:height="@dimen/checkbox_size" android:width="@dimen/checkbox_size" />
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -6,12 +6,18 @@
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="fill_parent"
android:minHeight="@dimen/checklist_item_min_height">
<RelativeLayout
android:layout_width="@dimen/button_width"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="@dimen/button_width"
android:layout_height="fill_parent"
android:textColor="@color/days_black"
android:gravity="center"/>
android:layout_width="@dimen/checkbox_size"
android:layout_height="@dimen/checkbox_size"
android:layout_centerInParent="true"
android:gravity="center"
android:button="@drawable/daily_checkbox"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<TextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"

View file

@ -20,15 +20,22 @@
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/checkBox"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="@dimen/button_width"
android:layout_height="match_parent"
android:checked="@{daily.completed}"
app:backgroundColor="@{daily.isDue ? daily.getLightTaskColor : @color/task_gray}"
android:gravity="center"
android:layout_gravity="center_horizontal" />
app:backgroundColor="@{daily.isDisplayedActive ? daily.getLightTaskColor : @color/task_gray}">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="@dimen/checkbox_size"
android:layout_height="@dimen/checkbox_size"
android:layout_centerInParent="true"
android:checked="@{daily.completed}"
android:gravity="center"
android:button="@drawable/daily_checkbox"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -36,7 +43,11 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="5dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:id="@+id/linearLayout"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
@ -53,7 +64,7 @@
android:id="@+id/textView6"
style="@style/CardText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:text="@{daily.notes}"
android:visibility="@{daily.notes != null ? View.VISIBLE : View.GONE}"/>
</LinearLayout>
@ -93,7 +104,7 @@
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
app:backgroundColor="@{daily.isDue ? daily.getLightTaskColor : @color/task_gray}"
app:backgroundColor="@{daily.isDisplayedActive ? daily.getLightTaskColor : @color/task_gray}"
android:visibility="@{daily.checklist.size == 0 ? View.VISIBLE : View.GONE}"
android:gravity="center"
android:layout_alignParentTop="true"

View file

@ -21,14 +21,22 @@
<LinearLayout
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="@dimen/button_width"
android:layout_height="match_parent"
app:backgroundColor="@{todo.completed ? @color/task_gray : todo.getLightTaskColor}">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="@dimen/button_width"
android:layout_height="fill_parent"
android:checked="@{todo.getCompleted}"
app:backgroundColor="@{todo.getLightTaskColor}"
android:gravity="center"/>
android:layout_width="@dimen/checkbox_size"
android:layout_height="@dimen/checkbox_size"
android:layout_centerInParent="true"
android:checked="@{todo.completed}"
android:gravity="center"
android:button="@drawable/todo_checkbox"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
@ -89,7 +97,7 @@
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
app:backgroundColor="@{todo.getLightTaskColor}"
app:backgroundColor="@{todo.completed ? @color/task_gray : todo.getLightTaskColor}"
android:visibility="@{todo.checklist.size == 0 ? View.VISIBLE : View.GONE}"
android:gravity="center"
android:layout_alignParentTop="true"

View file

@ -101,5 +101,8 @@
<color name="cell_separator">#c3c2c6</color>
<color name="checklist_separator">#ededed</color>
<color name="task_gray">#b5b5b5</color>
<color name="task_gray">#b7b7b7</color>
<color name="checkbox_fill">#50ffffff</color>
<color name="checkbox_checked_fill">#c8ffffff</color>
<color name="checkbox_stroke">#32000000</color>
</resources>

View file

@ -39,4 +39,7 @@
<dimen name="checklist_divider_width">14dp</dimen>
<dimen name="checklist_wrapper_width">36dp</dimen>
<dimen name="checklist_item_min_height">50dp</dimen>
<dimen name="daily_checkbox_corner_radius">2dp</dimen>
<dimen name="checkbox_size">30dp</dimen>
</resources>

View file

@ -124,4 +124,11 @@
<style name="Toolbar" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
</style>
<style name="HabitButton" parent="android:Widget.Button">
<item name="android:radius">0dp</item>
<item name="android:layout_margin">0dp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
</style>
</resources>

View file

@ -239,11 +239,9 @@ public class MainActivity extends AvatarActivityBase implements HabitRPGUserCall
}
public void onEvent(TaskLongPressedEvent event) {
showSnackbar("LongPress: " + event.Task.text);
}
public void onEvent(TaskCheckedEvent event) {
showSnackbar("ToDo Checked= " + event.Task.getText(), true);
mAPIHelper.updateTaskDirection(event.Task.getId(), event.Task.getCompleted() ? TaskDirection.down : TaskDirection.up, new TaskScoringCallback(this, event.Task.getId()));
}

View file

@ -27,6 +27,7 @@ public class TaskScoringCallback implements Callback<TaskDirectionData> {
public void success(TaskDirectionData taskDirectionData, Response response) {
Task task = new Select().from(Task.class).where(Condition.column("id").eq(taskId)).querySingle();
task.value = task.value + taskDirectionData.getDelta();
task.save();
this.mCallback.onTaskDataReceived(taskDirectionData);
}

View file

@ -392,6 +392,9 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
TaskCheckedEvent event = new TaskCheckedEvent();
event.Task = Item;
EventBus.getDefault().post(event);
Item.completed = !Item.getCompleted();
Item.save();
bindHolder(Item, getAdapterPosition());
}
} else {
Integer position = (Integer) ((ViewGroup) checkbox.getParent().getParent()).indexOfChild((View) checkbox.getParent());

View file

@ -409,4 +409,8 @@ public class Task extends BaseModel {
//TODO: check if daily is due
return !this.getCompleted();
}
public Boolean isDisplayedActive() {
return this.isDue() && !this.completed;
}
}