History fully works as intended: it shows deleted task lists and actual task lists with deleted or done tasks

Opening a task in History shows in read-only mode
Today View repaired
Some code cleanup
This commit is contained in:
BONNEVILLE Geoffroy
2017-12-22 16:29:23 +01:00
parent 074cf29d09
commit e5c150aaf5
12 changed files with 104 additions and 69 deletions

View File

@@ -92,8 +92,8 @@ public class TaskDataAccess implements AutoCloseable {
" LEFT JOIN " + DatabaseHelper.TASKLIST_TABLE_NAME + " LEFT JOIN " + DatabaseHelper.TASKLIST_TABLE_NAME +
" ON " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST + " ON " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST +
" = " + DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID + " = " + DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID +
" WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 + " WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_DONE + " = 0" +
" AND " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0 " AND " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_DELETED + " = 0"
, null); , null);
List<Task> tasks = new ArrayList<>(); List<Task> tasks = new ArrayList<>();
@@ -126,8 +126,8 @@ public class TaskDataAccess implements AutoCloseable {
public List<Task> getTodayTasks() { public List<Task> getTodayTasks() {
Cursor cursor = database.query(DatabaseHelper.TASKS_VIEW_TODAY_NAME, taskColumns, Cursor cursor = database.query(DatabaseHelper.TASKS_VIEW_TODAY_NAME, taskColumns,
DatabaseHelper.TASKS_COLUMN_DONE + " = " + 0 + DatabaseHelper.TASKS_COLUMN_DONE + " = 0" +
" AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = " + 0, " AND " + DatabaseHelper.TASKS_COLUMN_DELETED + " = 0",
null, null, null, null, null, null,
DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC"); DatabaseHelper.TASKS_COLUMN_CYCLE + ", " + DatabaseHelper.COLUMN_ID + " DESC");
return getTasksFromCursor(cursor); return getTasksFromCursor(cursor);
@@ -142,8 +142,6 @@ public class TaskDataAccess implements AutoCloseable {
} }
public void deleteTask(long id) { public void deleteTask(long id) {
/*database.delete(DatabaseHelper.TASKS_TABLE_NAME,
DatabaseHelper.COLUMN_ID + " = " + taskId, null);*/
update(id, DatabaseHelper.TASKS_COLUMN_DELETED, 1); update(id, DatabaseHelper.TASKS_COLUMN_DELETED, 1);
} }

View File

@@ -61,12 +61,13 @@ public class TaskListDataAccess implements AutoCloseable {
} }
public void deleteTaskList(long id) { public void deleteTaskList(long id) {
// Delete all related tasks // Mark all tasks as deleted
database.delete(DatabaseHelper.TASKS_TABLE_NAME, DatabaseHelper.TASKS_COLUMN_LIST ContentValues contentValues = new ContentValues();
+ " = " + id, null); contentValues.put(DatabaseHelper.TASKS_COLUMN_DELETED, 1);
// Delete list database.update(DatabaseHelper.TASKS_TABLE_NAME, contentValues, DatabaseHelper.TASKS_COLUMN_LIST
database.delete(DatabaseHelper.TASKLIST_TABLE_NAME, DatabaseHelper.COLUMN_ID
+ " = " + id, null); + " = " + id, null);
// Hide list
update(id, DatabaseHelper.TASKLIST_COLUMN_VISIBLE, 0);
} }
public void updateOrder(long id, int order) { public void updateOrder(long id, int order) {
@@ -77,21 +78,10 @@ public class TaskListDataAccess implements AutoCloseable {
update(id, DatabaseHelper.TASKLIST_COLUMN_NAME, name); update(id, DatabaseHelper.TASKLIST_COLUMN_NAME, name);
} }
public TaskList getTaskListByName(String name) { public List<TaskList> getTaskLists(boolean showInvisible) {
Cursor cursor = getTaskListByNameCursor(name);
TaskList taskList = null;
if (cursor.getCount() > 0) {
cursor.moveToFirst();
taskList = cursorToTaskList(cursor);
cursor.close();
}
return taskList;
}
public List<TaskList> getAllTaskLists() {
List<TaskList> taskLists = new ArrayList<>(); List<TaskList> taskLists = new ArrayList<>();
Cursor cursor = getAllTaskListsCursor(); Cursor cursor = showInvisible ? getInvisibleTaskListsCursor() : getVisibleTaskListsCursor();
cursor.moveToFirst(); cursor.moveToFirst();
while (!cursor.isAfterLast()) { while (!cursor.isAfterLast()) {
TaskList taskList = cursorToTaskList(cursor); TaskList taskList = cursorToTaskList(cursor);
@@ -113,18 +103,30 @@ public class TaskListDataAccess implements AutoCloseable {
database.update(DatabaseHelper.TASKLIST_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null); database.update(DatabaseHelper.TASKLIST_TABLE_NAME, contentValues, DatabaseHelper.COLUMN_ID + " = " + id, null);
} }
private Cursor getTaskListByNameCursor(String name) { private Cursor getVisibleTaskListsCursor() {
return database.query(true, DatabaseHelper.TASKLIST_TABLE_NAME, taskListColumns,
DatabaseHelper.TASKLIST_COLUMN_NAME + " = '" + name.replace("'", "''") + "'", null, null, null, null, null);
}
private Cursor getAllTaskListsCursor() {
return database.rawQuery("SELECT *," + return database.rawQuery("SELECT *," +
" (SELECT COUNT(*) " + " (SELECT COUNT(*) " +
" FROM " + DatabaseHelper.TASKS_TABLE_NAME + " FROM " + DatabaseHelper.TASKS_TABLE_NAME +
" WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST + " = " + " WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST + " = " +
DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID + ") AS " + DatabaseHelper.TASKLIST_COLUMN_TASK_COUNT + DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID + ") AS " + DatabaseHelper.TASKLIST_COLUMN_TASK_COUNT +
" FROM " + DatabaseHelper.TASKLIST_TABLE_NAME + " FROM " + DatabaseHelper.TASKLIST_TABLE_NAME +
" WHERE " + DatabaseHelper.TASKLIST_COLUMN_VISIBLE + " = " + 1 + " WHERE " + DatabaseHelper.TASKLIST_COLUMN_VISIBLE + " = 1" +
" ORDER BY " + DatabaseHelper.COLUMN_ORDER + " ASC ",
null);
}
private Cursor getInvisibleTaskListsCursor() {
return database.rawQuery("SELECT *," +
" (SELECT COUNT(*) " +
" FROM " + DatabaseHelper.TASKS_TABLE_NAME +
" WHERE " + DatabaseHelper.TASKS_TABLE_NAME + "." + DatabaseHelper.TASKS_COLUMN_LIST + " = " +
DatabaseHelper.TASKLIST_TABLE_NAME + "." + DatabaseHelper.COLUMN_ID +
" AND (" + DatabaseHelper.TASKS_COLUMN_DELETED + " = 1" +
" OR " + DatabaseHelper.TASKS_COLUMN_DONE + " = 1)" +
") AS " + DatabaseHelper.TASKLIST_COLUMN_TASK_COUNT +
" FROM " + DatabaseHelper.TASKLIST_TABLE_NAME +
" WHERE " + DatabaseHelper.TASKLIST_COLUMN_VISIBLE + " = 0" +
" OR " + DatabaseHelper.TASKLIST_COLUMN_TASK_COUNT + " > 0" +
" ORDER BY " + DatabaseHelper.COLUMN_ORDER + " ASC ", " ORDER BY " + DatabaseHelper.COLUMN_ORDER + " ASC ",
null); null);
} }
@@ -133,8 +135,6 @@ public class TaskListDataAccess implements AutoCloseable {
TaskList taskList = new TaskList(); TaskList taskList = new TaskList();
taskList.setId(cursor.getLong(0)); taskList.setId(cursor.getLong(0));
taskList.setName(cursor.getString(1)); taskList.setName(cursor.getString(1));
//taskList.setOrder(cursor.getInt(2));
//taskList.setVisible(cursor.getInt(3));
// Get "false" count column if it exists // Get "false" count column if it exists
if (cursor.getColumnCount() == 5) if (cursor.getColumnCount() == 5)
taskList.setTaskCount(cursor.getLong(4)); taskList.setTaskCount(cursor.getLong(4));

View File

@@ -77,7 +77,6 @@ public abstract class DynamicDialogFragment extends DialogFragment {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
// Send the negative button event back to the host activity // Send the negative button event back to the host activity
// Canceled creation, nothing to do // Canceled creation, nothing to do
//dialog.cancel();
onNegativeButtonClick(); onNegativeButtonClick();
} }
}); });
@@ -188,7 +187,7 @@ public abstract class DynamicDialogFragment extends DialogFragment {
} }
/** Helper function to get a View, without having to worry about the fact that is a Dialog or not*/ /** Helper function to get a View, without having to worry about the fact that is a Dialog or not*/
protected View findViewById(int id) { protected <T extends View> T findViewById(int id) {
if (getShowsDialog()) return getDialog().findViewById(id); if (getShowsDialog()) return getDialog().findViewById(id);
return getView().findViewById(id); return getView().findViewById(id);
} }

View File

@@ -22,6 +22,7 @@ import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import com.wismna.geoffroy.donext.R; import com.wismna.geoffroy.donext.R;
import com.wismna.geoffroy.donext.activities.HistoryActivity;
import com.wismna.geoffroy.donext.adapters.SectionsPagerAdapter; import com.wismna.geoffroy.donext.adapters.SectionsPagerAdapter;
import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter; import com.wismna.geoffroy.donext.adapters.TaskRecyclerViewAdapter;
import com.wismna.geoffroy.donext.dao.Task; import com.wismna.geoffroy.donext.dao.Task;
@@ -100,12 +101,12 @@ public class MainFragment extends Fragment implements
updateTaskLists(activity); updateTaskLists(activity);
} }
private void updateTaskLists(AppCompatActivity activity) private void updateTaskLists(AppCompatActivity activity) {
{ boolean isHistoryActivity = activity instanceof HistoryActivity;
// Access database to retrieve Tabs // Access database to retrieve Tabs
List<TaskList> taskLists; List<TaskList> taskLists;
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(activity)) { try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(activity)) {
taskLists = taskListDataAccess.getAllTaskLists(); taskLists = taskListDataAccess.getTaskLists(isHistoryActivity);
// Create the adapter that will return a fragment for each of the three // Create the adapter that will return a fragment for each of the three
// primary sections of the activity. // primary sections of the activity.
@@ -138,7 +139,7 @@ public class MainFragment extends Fragment implements
tabLayout = mView.findViewById(R.id.tabs); tabLayout = mView.findViewById(R.id.tabs);
// Hide the tabs if there is only one task list // Hide the tabs if there is only one task list
tabLayout.setVisibility(taskLists.size() == 1 ? View.GONE : View.VISIBLE); tabLayout.setVisibility(taskLists.size() == 1 && !isHistoryActivity ? View.GONE : View.VISIBLE);
tabLayout.setupWithViewPager(mViewPager); tabLayout.setupWithViewPager(mViewPager);
// Handles scroll detection (only available for SDK version >=23) // Handles scroll detection (only available for SDK version >=23)
@@ -156,7 +157,7 @@ public class MainFragment extends Fragment implements
else { else {
ListView listView = mView.findViewById(R.id.list); ListView listView = mView.findViewById(R.id.list);
// Hide the list if there is only one task list // Hide the list if there is only one task list
listView.setVisibility(taskLists.size() == 1 ? View.GONE : View.VISIBLE); listView.setVisibility(taskLists.size() == 1 && !isHistoryActivity ? View.GONE : View.VISIBLE);
//listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, taskLists)); //listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, taskLists));
listView.setAdapter(new ArrayAdapter<>(activity, R.layout.list_tasklist_item, taskLists)); listView.setAdapter(new ArrayAdapter<>(activity, R.layout.list_tasklist_item, taskLists));
//listView.setSelection(lastOpenedList); //listView.setSelection(lastOpenedList);

View File

@@ -1,5 +1,6 @@
package com.wismna.geoffroy.donext.fragments; package com.wismna.geoffroy.donext.fragments;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@@ -14,8 +15,10 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.wismna.geoffroy.donext.R; import com.wismna.geoffroy.donext.R;
import com.wismna.geoffroy.donext.activities.HistoryActivity;
import com.wismna.geoffroy.donext.dao.Task; import com.wismna.geoffroy.donext.dao.Task;
import com.wismna.geoffroy.donext.dao.TaskList; import com.wismna.geoffroy.donext.dao.TaskList;
import com.wismna.geoffroy.donext.widgets.InterceptTouchRelativeLayout;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
@@ -67,7 +70,14 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
super.onStart(); super.onStart();
// Set Task Form specific information at that point because we are sure that the view is // Set Task Form specific information at that point because we are sure that the view is
// entirely inflated (with the content fragment) // entirely inflated (with the content fragment)
setTaskValues(); Activity activity = getActivity();
assert activity != null;
if (activity instanceof HistoryActivity) {
InterceptTouchRelativeLayout layout = findViewById(R.id.new_task_layout);
layout.setInterceptTouchEvents(true);
}
setTaskValues(activity);
} }
@Override @Override
@@ -94,12 +104,12 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
dismiss(); dismiss();
} }
private void setTaskValues() { private void setTaskValues(Activity activity) {
// Populate spinner with task lists // Populate spinner with task lists
Spinner spinner = (Spinner) findViewById(R.id.new_task_list); Spinner spinner = findViewById(R.id.new_task_list);
// Create an ArrayAdapter using the string array and a default spinner layout // Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<TaskList> adapter = new ArrayAdapter<>( ArrayAdapter<TaskList> adapter = new ArrayAdapter<>(
getActivity(), android.R.layout.simple_spinner_item, taskLists); activity, android.R.layout.simple_spinner_item, taskLists);
// Specify the layout to use when the list of choices appears // Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter); spinner.setAdapter(adapter);
@@ -110,16 +120,16 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
int id = args.getInt("list"); int id = args.getInt("list");
spinner.setSelection(id); spinner.setSelection(id);
CheckBox checkBox = (CheckBox) findViewById(R.id.new_task_today); CheckBox checkBox = findViewById(R.id.new_task_today);
TextView todayLabel = (TextView) findViewById(R.id.new_task_today_label); TextView todayLabel = findViewById(R.id.new_task_today_label);
boolean isTodayActive = args.getBoolean("today"); boolean isTodayActive = args.getBoolean("today");
checkBox.setVisibility(isTodayActive ? View.VISIBLE : View.GONE); checkBox.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
todayLabel.setVisibility(isTodayActive ? View.VISIBLE : View.GONE); todayLabel.setVisibility(isTodayActive ? View.VISIBLE : View.GONE);
// Get date picker // Get date picker
final DatePicker dueDatePicker = (DatePicker) findViewById(R.id.new_task_due_date); final DatePicker dueDatePicker = findViewById(R.id.new_task_due_date);
// Handle due date spinner depending on check box // Handle due date spinner depending on check box
CheckBox setDueDate = (CheckBox) findViewById(R.id.new_task_due_date_set); CheckBox setDueDate = findViewById(R.id.new_task_due_date_set);
setDueDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { setDueDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -128,8 +138,8 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
}); });
// Handle priority changes // Handle priority changes
final TextView tooltip = (TextView) findViewById(R.id.new_task_priority_tooltip); final TextView tooltip = findViewById(R.id.new_task_priority_tooltip);
SeekBar seekBar = (SeekBar) findViewById(R.id.new_task_priority); SeekBar seekBar = findViewById(R.id.new_task_priority);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@@ -150,9 +160,9 @@ public class TaskFormDialogFragment extends DynamicDialogFragment {
// Set other properties if they exist // Set other properties if they exist
if (task != null) { if (task != null) {
EditText titleText = (EditText) findViewById(R.id.new_task_name); EditText titleText = findViewById(R.id.new_task_name);
titleText.setText(task.getName()); titleText.setText(task.getName());
EditText descText = (EditText) findViewById(R.id.new_task_description); EditText descText = findViewById(R.id.new_task_description);
descText.setText(task.getDescription()); descText.setText(task.getDescription());
seekBar.setProgress(task.getPriority()); seekBar.setProgress(task.getPriority());

View File

@@ -73,11 +73,11 @@ public class TaskListsDialogFragment extends DynamicDialogFragment implements
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
Button createTaskListButton = (Button) findViewById(R.id.new_task_list_button); Button createTaskListButton = findViewById(R.id.new_task_list_button);
createTaskListButton.setOnClickListener(new View.OnClickListener() { createTaskListButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
EditText editText = (EditText) findViewById(R.id.new_task_list_name); EditText editText = findViewById(R.id.new_task_list_name);
String text = editText.getText().toString(); String text = editText.getText().toString();
if (text.matches("")) { if (text.matches("")) {
editText.setError(getResources().getString(R.string.task_list_new_list_error)); editText.setError(getResources().getString(R.string.task_list_new_list_error));
@@ -126,7 +126,7 @@ public class TaskListsDialogFragment extends DynamicDialogFragment implements
} }
private void toggleVisibleCreateNewTaskListLayout() { private void toggleVisibleCreateNewTaskListLayout() {
LinearLayout layout = (LinearLayout) findViewById(R.id.new_task_list_layout); LinearLayout layout = findViewById(R.id.new_task_list_layout);
int taskListCount = taskListRecyclerViewAdapter.getItemCount(); int taskListCount = taskListRecyclerViewAdapter.getItemCount();
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "5"); String maxTaskListsString = sharedPref.getString("pref_conf_max_lists", "5");
@@ -220,7 +220,7 @@ public class TaskListsDialogFragment extends DynamicDialogFragment implements
@Override @Override
protected List<TaskList> doInBackground(TaskListDataAccess... params) { protected List<TaskList> doInBackground(TaskListDataAccess... params) {
TaskListDataAccess taskListDataAccess = params[0]; TaskListDataAccess taskListDataAccess = params[0];
return taskListDataAccess.getAllTaskLists(); return taskListDataAccess.getTaskLists(false);
} }
@Override @Override
@@ -233,7 +233,7 @@ public class TaskListsDialogFragment extends DynamicDialogFragment implements
// Set the adapter // Set the adapter
Context context = fragment.getContext(); Context context = fragment.getContext();
RecyclerView recyclerView = (RecyclerView) fragment.findViewById(R.id.task_lists_view); RecyclerView recyclerView = fragment.findViewById(R.id.task_lists_view);
recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(fragment.taskListRecyclerViewAdapter); recyclerView.setAdapter(fragment.taskListRecyclerViewAdapter);

View File

@@ -89,13 +89,12 @@ public class TasksFragment extends Fragment implements
if (getArguments() != null) { if (getArguments() != null) {
taskListId = getArguments().getLong(TASK_LIST_ID); taskListId = getArguments().getLong(TASK_LIST_ID);
}
Activity parentActivity = getActivity(); Activity parentActivity = getActivity();
if (parentActivity instanceof HistoryActivity) isHistory = true; if (parentActivity instanceof HistoryActivity) isHistory = true;
if (parentActivity instanceof TodayActivity) isTodayView = true; if (parentActivity instanceof TodayActivity) isTodayView = true;
// TODO: this does not work! No tasks are shown
mAdapter = (MainFragment)getParentFragment(); mAdapter = (MainFragment)getParentFragment();
} }
}
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
@@ -118,7 +117,6 @@ public class TasksFragment extends Fragment implements
} }
recyclerView.setAdapter(taskRecyclerViewAdapter); recyclerView.setAdapter(taskRecyclerViewAdapter);
// TODO: check that this works
if (!isHistory) { if (!isHistory) {
// Set ItemTouch helper in RecyclerView to handle swipe move on elements // Set ItemTouch helper in RecyclerView to handle swipe move on elements
ItemTouchHelper.Callback callback = new TaskTouchHelper(this, ItemTouchHelper.Callback callback = new TaskTouchHelper(this,
@@ -156,7 +154,7 @@ public class TasksFragment extends Fragment implements
} }
else { else {
try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(getActivity())) { try (TaskListDataAccess taskListDataAccess = new TaskListDataAccess(getActivity())) {
taskLists = taskListDataAccess.getAllTaskLists(); taskLists = taskListDataAccess.getTaskLists(isHistory);
} }
for (TaskList taskList : for (TaskList taskList :
taskLists) { taskLists) {
@@ -173,7 +171,7 @@ public class TasksFragment extends Fragment implements
taskDialogFragment.setArguments(args); taskDialogFragment.setArguments(args);
// Open the fragment as a dialog or as full-screen depending on screen size // Open the fragment as a dialog or as full-screen depending on screen size
String title = getString(R.string.action_edit_task); String title = getString(isHistory ? R.string.action_view_task : R.string.action_edit_task);
assert manager != null; assert manager != null;
taskDialogFragment.showFragment(manager, title, isLargeLayout); taskDialogFragment.showFragment(manager, title, isLargeLayout);
} }
@@ -219,7 +217,6 @@ public class TasksFragment extends Fragment implements
if (remainingTaskCount == 0) remainingTasksView.setText(""); if (remainingTaskCount == 0) remainingTasksView.setText("");
else remainingTasksView.setText(resources.getQuantityString(R.plurals.task_remaining, remainingTaskCount, remainingTaskCount)); else remainingTasksView.setText(resources.getQuantityString(R.plurals.task_remaining, remainingTaskCount, remainingTaskCount));
//recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);
return true; return true;
} }
}); });

View File

@@ -55,8 +55,8 @@ public class TodayFormDialogFragment extends DynamicDialogFragment {
} }
private void setLayoutValues(List<Task> tasks) { private void setLayoutValues(List<Task> tasks) {
EditText editText = (EditText) findViewById(R.id.today_search); EditText editText = findViewById(R.id.today_search);
final ListView listView = (ListView) findViewById(R.id.today_tasks); final ListView listView = findViewById(R.id.today_tasks);
final TodayArrayAdapter adapter = new TodayArrayAdapter(getActivity(), tasks); final TodayArrayAdapter adapter = new TodayArrayAdapter(getActivity(), tasks);
listView.setAdapter(adapter); listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

View File

@@ -0,0 +1,28 @@
package com.wismna.geoffroy.donext.widgets;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;
/**
* Created by GBE on 22/12/2017.
* This class extends RelativeLayout to intercept touch event (and disable them)
*/
public class InterceptTouchRelativeLayout extends RelativeLayout {
private boolean interceptTouchEvents = false;
public InterceptTouchRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setInterceptTouchEvents(boolean interceptTouchEvents) {
this.interceptTouchEvents = interceptTouchEvents;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return interceptTouchEvents || super.onInterceptTouchEvent(ev);
}
}

View File

@@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light"> android:background="@android:color/background_light">
<RelativeLayout <com.wismna.geoffroy.donext.widgets.InterceptTouchRelativeLayout
android:id="@+id/new_task_layout" android:id="@+id/new_task_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -116,5 +116,5 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/new_task_due_date_label" /> android:layout_below="@id/new_task_due_date_label" />
</RelativeLayout> </com.wismna.geoffroy.donext.widgets.InterceptTouchRelativeLayout>
</ScrollView> </ScrollView>

View File

@@ -62,4 +62,5 @@
<string name="action_history">Historique</string> <string name="action_history">Historique</string>
<string name="task_list_ok">OK</string> <string name="task_list_ok">OK</string>
<string name="title_activity_history">Historique</string> <string name="title_activity_history">Historique</string>
<string name="action_view_task">Tâche</string>
</resources> </resources>

View File

@@ -83,5 +83,6 @@
<!-- String related to History --> <!-- String related to History -->
<string name="title_activity_history">History</string> <string name="title_activity_history">History</string>
<string name="action_view_task">Task</string>
</resources> </resources>