Add task list name in Today select tasks dialog (but Today is broken and it shows empty task lists)

This commit is contained in:
2017-03-23 23:17:34 -04:00
parent 799ec9a058
commit 77543dd71f
8 changed files with 58 additions and 12 deletions

Binary file not shown.

View File

@@ -140,6 +140,7 @@ public class MainActivity extends AppCompatActivity implements TasksFragment.Tas
// Handles today list
MenuItem todayListItem = menu.findItem(R.id.action_todayList);
if (todayListItem == null) return false;
todayListItem.setVisible(sharedPref.getBoolean("pref_conf_today_enable", false));
return super.onPrepareOptionsMenu(menu);

View File

@@ -66,7 +66,7 @@ public class TodayActivity extends AppCompatActivity
public void onNewTaskClick(View view) {
TodayFormDialogFragment taskDialogFragment =
TodayFormDialogFragment.newInstance(this, TodayActivity.this);
TodayFormDialogFragment.newInstance(TodayActivity.this);
// Set some configuration values for the dialog
Bundle args = new Bundle();

View File

@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.wismna.geoffroy.donext.R;
@@ -34,15 +35,18 @@ public class TodayArrayAdapter extends ArrayAdapter<Task> {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_task_item, parent, false);
}
TextView titleView = (TextView) convertView.findViewById(R.id.task_list_item_title);
TextView taskView = (TextView) convertView.findViewById(R.id.task_list_item_tasklist);
LinearLayout layoutView = (LinearLayout) convertView.findViewById(R.id.task_list_item_layout);
Task item = this.getItem(position);
if (item != null) {
titleView.setText(item.getName());
taskView.setText(item.getTaskListName());
if (item.isToday()) {
titleView.setTypeface(titleView.getTypeface(), Typeface.BOLD);
titleView.setBackgroundColor(Color.parseColor("#B2DFDB"));
layoutView.setBackgroundColor(Color.parseColor("#B2DFDB"));
} else {
titleView.setTypeface(Typeface.DEFAULT);
titleView.setBackgroundColor(Color.WHITE);
layoutView.setBackgroundColor(Color.WHITE);
}
}
return convertView;

View File

@@ -87,6 +87,7 @@ public class Task {
return taskListName;
}
// TODO: implement this via SQL
public void setTaskListName(String taskListName) {
this.taskListName = taskListName;
}

View File

@@ -83,12 +83,38 @@ public class TaskDataAccess implements AutoCloseable {
}
public List<Task> getAllTasks() {
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
/*Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME, taskColumns,
DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 +
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0,
null, null, null,
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
return getTasksFromCursor(cursor);
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");*/
Cursor cursor = database.rawQuery("SELECT " +
DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID + "," +
DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_NAME + "," +
DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_TODAYDATE + "," +
DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.TASKLIST_COLUMN_NAME + " AS tasklistname " +
" FROM " + DatabaseHelper.TASKLIST_TABLE_NAME +
" LEFT JOIN " + DatabaseHelper.TASKS_TABLE_NAME +
" ON " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST +
" = " + DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID
, null);
List<Task> tasks = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Task task = new Task();
task.setId(cursor.getLong(0));
task.setName(cursor.getString(1));
task.setTodayDate(cursor.getString(2));
task.setTaskListName(cursor.getString(3));
tasks.add(task);
cursor.moveToNext();
}
// make sure to close the cursor
cursor.close();
return tasks;
//return getTasksFromCursor(cursor);
}
public List<Task> getAllTasksFromList(long id) {

View File

@@ -37,7 +37,7 @@ public class TodayFormDialogFragment extends DynamicDialogFragment {
private TodayFormDialogFragment.TodayTaskListener mListener;
private final List<Task> mUpdatedTasks = new ArrayList<>();
public static TodayFormDialogFragment newInstance(Context context, TodayTaskListener todayTaskListener) {
public static TodayFormDialogFragment newInstance(TodayTaskListener todayTaskListener) {
TodayFormDialogFragment fragment = new TodayFormDialogFragment();
fragment.mListener = todayTaskListener;

View File

@@ -1,8 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/task_list_item_title"
android:id="@+id/task_list_item_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:textSize="20sp" />
android:orientation="vertical">
<TextView
android:id="@+id/task_list_item_tasklist"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp" />
<TextView
android:id="@+id/task_list_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_marginStart="20dp"
android:layout_marginBottom="4dp"/>
</LinearLayout>