Refactored to pass editable flag to the AstridActivity when task item clicked. This will make it easier to choose whether to launch the edit page or the comments page

pull/14/head
Sam Bosley 12 years ago
parent eae50fdae1
commit 61eabcc3cf

@ -52,7 +52,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
}
@Override
public void onTaskListItemClicked(long taskId) {
public void onTaskListItemClicked(long taskId, boolean editable) {
// Do nothing
}

@ -22,7 +22,9 @@ import android.widget.Toast;
import com.timsu.astrid.R;
import com.todoroo.aacenc.RecognizerApi.RecognizerApiListener;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.CommentsFragment;
@ -34,6 +36,7 @@ import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.api.IntentFilter;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.core.SearchFilter;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.StartupService;
@ -70,6 +73,9 @@ public class AstridActivity extends FragmentActivity
private final RepeatConfirmationReceiver repeatConfirmationReceiver = new RepeatConfirmationReceiver();
@Autowired
private TaskDao taskDao;
public FilterListFragment getFilterListFragment() {
FilterListFragment frag = (FilterListFragment) getSupportFragmentManager()
.findFragmentByTag(FilterListFragment.TAG_FILTERLIST_FRAGMENT);
@ -101,6 +107,7 @@ public class AstridActivity extends FragmentActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
DependencyInjectionService.getInstance().inject(this);
super.onCreate(savedInstanceState);
ContextManager.setContext(this);
StatisticsService.sessionStart(this);
@ -234,6 +241,13 @@ public class AstridActivity extends FragmentActivity
@Override
public void onTaskListItemClicked(long taskId) {
Task task = taskDao.fetch(taskId, Task.FLAGS, Task.USER_ID);
if (task != null)
onTaskListItemClicked(taskId, task.isEditable());
}
@Override
public void onTaskListItemClicked(long taskId, boolean editable) {
Intent intent = new Intent(this, TaskEditActivity.class);
intent.putExtra(TaskEditFragment.TOKEN_ID, taskId);
getIntent().putExtra(TaskEditFragment.TOKEN_ID, taskId); // Needs to be in activity intent so that TEA onResume doesn't create a blank activity

@ -53,7 +53,7 @@ public final class ShareLinkActivity extends TaskListActivity {
task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT));
taskService.save(task);
handled = true;
onTaskListItemClicked(task.getId());
onTaskListItemClicked(task.getId(), true);
}
}
}

@ -37,8 +37,8 @@ import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.CommentsFragment;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.adapter.FilterAdapter;
import com.todoroo.astrid.adapter.TaskListFragmentPagerAdapter;
@ -453,13 +453,13 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
if (getIntent().hasExtra(OPEN_TASK)) {
long id = getIntent().getLongExtra(OPEN_TASK, 0);
if (id > 0) {
onTaskListItemClicked(id);
onTaskListItemClicked(id, true);
} else {
TaskListFragment tlf = getTaskListFragment();
if (tlf != null) {
Task result = tlf.quickAddBar.quickAddTask("", true); //$NON-NLS-1$
if (result != null)
onTaskListItemClicked(result.getId());
onTaskListItemClicked(result.getId(), true);
}
}
if (fragmentLayout == LAYOUT_SINGLE)
@ -468,14 +468,14 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
}
@Override
public void onTaskListItemClicked(long taskId) {
public void onTaskListItemClicked(long taskId, boolean editable) {
if (fragmentLayout != LAYOUT_SINGLE)
getIntent().putExtra(OPEN_TASK, taskId);
CommentsFragment tuf = getTagUpdatesFragment();
if (tuf != null)
tuf.getView().setVisibility(View.INVISIBLE);
super.onTaskListItemClicked(taskId);
super.onTaskListItemClicked(taskId, editable);
}
public void setListsTitle(String title) {

@ -66,8 +66,8 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.CommentsActivity;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
@ -281,6 +281,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
*/
public interface OnTaskListItemClickedListener {
public void onTaskListItemClicked(long taskId);
public void onTaskListItemClicked(long taskId, boolean editable);
}
@Override
@ -367,9 +368,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
if(task.isDeleted())
return;
if (task.isEditable()) {
onTaskListItemClicked(id);
}
onTaskListItemClicked(id, task.isEditable());
}
});
}
@ -1331,8 +1330,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
startActivityForResult(intent, ACTIVITY_SETTINGS);
}
public void onTaskListItemClicked(long taskId) {
mListener.onTaskListItemClicked(taskId);
public void onTaskListItemClicked(long taskId, boolean editable) {
mListener.onTaskListItemClicked(taskId, editable);
}
protected void toggleDragDrop(boolean newState) {

@ -1015,16 +1015,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
return;
long taskId = viewHolder.task.getId();
if (viewHolder.task.isEditable()) {
editTask(taskId);
}
fragment.onTaskListItemClicked(taskId, viewHolder.task.isEditable());
}
}
private void editTask(long taskId) {
fragment.onTaskListItemClicked(taskId);
}
/**
* Call me when the parent presses trackpad
*/
@ -1116,7 +1110,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
final CheckableImageView checkBoxView = viewHolder.completeBox; {
checkBoxView.setChecked(task.isCompleted());
// disable checkbox if task is readonly
checkBoxView.setEnabled(!viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY));
checkBoxView.setEnabled(viewHolder.task.isEditable());
int value = task.getValue(Task.IMPORTANCE);
if (value >= IMPORTANCE_RESOURCES.length)

@ -61,6 +61,7 @@ public class DateChangedAlerts {
final Dialog d = new Dialog(activity, R.style.ReminderDialog);
final long taskId = task.getId();
final boolean editable = task.isEditable();
d.setContentView(R.layout.astrid_reminder_view);
Button okButton = (Button) d.findViewById(R.id.reminder_complete);
@ -80,7 +81,7 @@ public class DateChangedAlerts {
@Override
public void onClick(View v) {
d.dismiss();
activity.onTaskListItemClicked(taskId);
activity.onTaskListItemClicked(taskId, editable);
}
});

@ -153,7 +153,7 @@ public class QuickAddBar extends LinearLayout {
public void onClick(View v) {
Task task = quickAddTask(quickAddBox.getText().toString(), true);
if (task != null && task.getValue(Task.TITLE).length() == 0) {
mListener.onTaskListItemClicked(task.getId());
mListener.onTaskListItemClicked(task.getId(), true);
}
}
});
@ -178,7 +178,7 @@ public class QuickAddBar extends LinearLayout {
if (task == null)
return true;
mListener.onTaskListItemClicked(task.getId());
mListener.onTaskListItemClicked(task.getId(), true);
return true;
}
});

Loading…
Cancel
Save