|
|
|
|
@ -2,8 +2,15 @@ package com.todoroo.astrid.tags.reusable;
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.app.ProgressDialog;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
import android.support.v4.view.Menu;
|
|
|
|
|
import android.support.v4.view.MenuItem;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
@ -16,6 +23,7 @@ import com.todoroo.astrid.actfm.TagViewFragment;
|
|
|
|
|
import com.todoroo.astrid.adapter.TaskAdapter;
|
|
|
|
|
import com.todoroo.astrid.data.TagData;
|
|
|
|
|
import com.todoroo.astrid.data.Task;
|
|
|
|
|
import com.todoroo.astrid.helper.AsyncImageView;
|
|
|
|
|
import com.todoroo.astrid.service.TagDataService;
|
|
|
|
|
import com.todoroo.astrid.utility.Flags;
|
|
|
|
|
|
|
|
|
|
@ -23,6 +31,8 @@ public class FeaturedTaskListFragment extends TagViewFragment {
|
|
|
|
|
|
|
|
|
|
@Autowired private TagDataService tagDataService;
|
|
|
|
|
|
|
|
|
|
private static final int MENU_CLONE_LIST = R.string.actfm_feat_list_clone;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) {
|
|
|
|
|
return new ReusableTaskAdapter(this, R.layout.reusable_task_adapter_row,
|
|
|
|
|
@ -46,13 +56,58 @@ public class FeaturedTaskListFragment extends TagViewFragment {
|
|
|
|
|
return R.layout.task_list_body_featured_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
|
|
|
|
|
|
MenuItem item = menu.add(Menu.NONE, MENU_CLONE_LIST, 0, R.string.actfm_feat_list_clone);
|
|
|
|
|
item.setIcon(R.drawable.ic_menu_list_copy);
|
|
|
|
|
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean handleOptionsMenuItemSelected(int id, Intent intent) {
|
|
|
|
|
if (id == MENU_CLONE_LIST) {
|
|
|
|
|
cloneList();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return super.handleOptionsMenuItemSelected(id, intent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
|
|
|
|
ContextMenuInfo menuInfo) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void setUpMembersGallery() {
|
|
|
|
|
// Repurposed this method to set up listener for clone list button
|
|
|
|
|
View clone = getView().findViewById(R.id.clone_list);
|
|
|
|
|
clone.setOnClickListener(new OnClickListener() {
|
|
|
|
|
// Repurposed this method to set up the description view
|
|
|
|
|
AsyncImageView imageView = (AsyncImageView) getView().findViewById(R.id.url_image);
|
|
|
|
|
String imageUrl = tagData.getValue(TagData.PICTURE);
|
|
|
|
|
if (!TextUtils.isEmpty(imageUrl)) {
|
|
|
|
|
imageView.setVisibility(View.VISIBLE);
|
|
|
|
|
imageView.setDefaultImageResource(R.drawable.default_list_0);
|
|
|
|
|
imageView.setUrl(imageUrl);
|
|
|
|
|
} else {
|
|
|
|
|
imageView.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final String description = tagData.getValue(TagData.TAG_DESCRIPTION);
|
|
|
|
|
final Resources r = getActivity().getResources();
|
|
|
|
|
TextView desc = (TextView) getView().findViewById(R.id.feat_list_desc);
|
|
|
|
|
desc.setText(description);
|
|
|
|
|
desc.setLines(4);
|
|
|
|
|
desc.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
DialogUtilities.okDialog(getActivity(), r.getString(R.string.DLG_information_title),
|
|
|
|
|
0, description, null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cloneList() {
|
|
|
|
|
// Clone list
|
|
|
|
|
if (taskAdapter == null || taskAdapter.getCount() == 0) {
|
|
|
|
|
Toast.makeText(getActivity(), R.string.actfm_feat_list_clone_empty, Toast.LENGTH_LONG).show();
|
|
|
|
|
@ -100,8 +155,6 @@ public class FeaturedTaskListFragment extends TagViewFragment {
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void refresh() {
|
|
|
|
|
|