|
|
@ -4,8 +4,11 @@ import android.app.Activity;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v4.app.ActionBar;
|
|
|
|
import android.support.v4.app.ActionBar;
|
|
|
|
|
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
|
|
|
|
import android.view.ViewGroup.LayoutParams;
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.PopupWindow.OnDismissListener;
|
|
|
|
import android.widget.PopupWindow.OnDismissListener;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
@ -16,7 +19,7 @@ import com.todoroo.astrid.actfm.TagSettingsActivity;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.api.Filter;
|
|
|
|
import com.todoroo.astrid.api.FilterListItem;
|
|
|
|
import com.todoroo.astrid.api.FilterListItem;
|
|
|
|
import com.todoroo.astrid.service.ThemeService;
|
|
|
|
import com.todoroo.astrid.service.ThemeService;
|
|
|
|
import com.todoroo.astrid.ui.ListDropdownPopover;
|
|
|
|
import com.todoroo.astrid.ui.FragmentPopover;
|
|
|
|
|
|
|
|
|
|
|
|
public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
|
|
|
|
|
|
|
@ -24,13 +27,14 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
private View listsNav;
|
|
|
|
private View listsNav;
|
|
|
|
private TextView lists;
|
|
|
|
private TextView lists;
|
|
|
|
|
|
|
|
|
|
|
|
private ListDropdownPopover popover;
|
|
|
|
private FragmentPopover listsPopover;
|
|
|
|
|
|
|
|
private FragmentPopover editPopover;
|
|
|
|
|
|
|
|
|
|
|
|
private final OnClickListener popupMenuClickListener = new OnClickListener() {
|
|
|
|
private final OnClickListener popupMenuClickListener = new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
setListsDropdownSelected(true);
|
|
|
|
setListsDropdownSelected(true);
|
|
|
|
popover.show(v);
|
|
|
|
listsPopover.show(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -70,6 +74,7 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
fragmentLayout = LAYOUT_TRIPLE;
|
|
|
|
fragmentLayout = LAYOUT_TRIPLE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fragmentLayout = LAYOUT_DOUBLE;
|
|
|
|
fragmentLayout = LAYOUT_DOUBLE;
|
|
|
|
|
|
|
|
createEditPopover();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setupFragment(FilterListActivity.TAG_FILTERLIST_FRAGMENT,
|
|
|
|
setupFragment(FilterListActivity.TAG_FILTERLIST_FRAGMENT,
|
|
|
@ -78,14 +83,14 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
fragmentLayout = LAYOUT_SINGLE;
|
|
|
|
fragmentLayout = LAYOUT_SINGLE;
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
listsNav.setOnClickListener(popupMenuClickListener);
|
|
|
|
listsNav.setOnClickListener(popupMenuClickListener);
|
|
|
|
createPopover();
|
|
|
|
createListsPopover();
|
|
|
|
setupPopoverWithFilterList((FilterListActivity) setupFragment(FilterListActivity.TAG_FILTERLIST_FRAGMENT, 0, FilterListActivity.class));
|
|
|
|
setupPopoverWithFilterList((FilterListActivity) setupFragment(FilterListActivity.TAG_FILTERLIST_FRAGMENT, 0, FilterListActivity.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void createPopover() {
|
|
|
|
private void createListsPopover() {
|
|
|
|
popover = new ListDropdownPopover(TaskListWrapperActivity.this);
|
|
|
|
listsPopover = new FragmentPopover(this, R.layout.list_dropdown_popover);
|
|
|
|
popover.setOnDismissListener(new OnDismissListener() {
|
|
|
|
listsPopover.setOnDismissListener(new OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onDismiss() {
|
|
|
|
public void onDismiss() {
|
|
|
|
setListsDropdownSelected(false);
|
|
|
|
setListsDropdownSelected(false);
|
|
|
@ -93,22 +98,52 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createEditPopover() {
|
|
|
|
|
|
|
|
editPopover = new FragmentPopover(this, R.layout.taskedit_popover);
|
|
|
|
|
|
|
|
editPopover.setOnDismissListener(new OnDismissListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onDismiss() {
|
|
|
|
|
|
|
|
TaskEditActivity tea = getTaskEditFragment();
|
|
|
|
|
|
|
|
if (tea != null)
|
|
|
|
|
|
|
|
tea.save(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupPopoverWithFragment(FragmentPopover popover, Fragment frag, LayoutParams params) {
|
|
|
|
|
|
|
|
if (popover != null) {
|
|
|
|
|
|
|
|
View view = frag.getView();
|
|
|
|
|
|
|
|
if (view != null) {
|
|
|
|
|
|
|
|
FrameLayout parent = (FrameLayout) view.getParent();
|
|
|
|
|
|
|
|
if (parent != null)
|
|
|
|
|
|
|
|
parent.removeView(view);
|
|
|
|
|
|
|
|
if (params == null)
|
|
|
|
|
|
|
|
popover.setContent(view);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
popover.setContent(view, params);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setupPopoverWithFilterList(FilterListActivity fla) {
|
|
|
|
public void setupPopoverWithFilterList(FilterListActivity fla) {
|
|
|
|
if (popover != null) {
|
|
|
|
setupPopoverWithFragment(listsPopover, fla, null);
|
|
|
|
View view = fla.getView();
|
|
|
|
}
|
|
|
|
if (view != null) {
|
|
|
|
|
|
|
|
FrameLayout parent = (FrameLayout) view.getParent();
|
|
|
|
@Override
|
|
|
|
if (parent != null)
|
|
|
|
public void onTaskListItemClicked(long taskId) {
|
|
|
|
parent.removeView(view);
|
|
|
|
super.onTaskListItemClicked(taskId);
|
|
|
|
popover.setContent(view);
|
|
|
|
if (fragmentLayout == LAYOUT_DOUBLE && getTaskEditFragment() != null) {
|
|
|
|
}
|
|
|
|
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
|
|
|
|
|
|
|
setupPopoverWithFragment(editPopover, getTaskEditFragment(), new LayoutParams((int) (400 * metrics.density), (int) (600 * metrics.density)));
|
|
|
|
|
|
|
|
editPopover.show(listsNav);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onFilterItemClicked(FilterListItem item) {
|
|
|
|
public boolean onFilterItemClicked(FilterListItem item) {
|
|
|
|
if (popover != null)
|
|
|
|
if (listsPopover != null)
|
|
|
|
popover.dismiss();
|
|
|
|
listsPopover.dismiss();
|
|
|
|
return super.onFilterItemClicked(item);
|
|
|
|
return super.onFilterItemClicked(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -132,8 +167,10 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
super.onPause();
|
|
|
|
if (popover != null)
|
|
|
|
if (listsPopover != null)
|
|
|
|
popover.dismiss();
|
|
|
|
listsPopover.dismiss();
|
|
|
|
|
|
|
|
if (editPopover != null)
|
|
|
|
|
|
|
|
editPopover.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setSelectedItem(Filter item) {
|
|
|
|
public void setSelectedItem(Filter item) {
|
|
|
|