Mostly working task edit popover

pull/14/head
Sam Bosley 13 years ago committed by Andrew Shaw
parent d5b704badf
commit 537beaa062

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/task_edit_dialog_background_white"
android:padding="10dip"
android:layout_below="@+id/gdi_arrow_up"/>
<ImageView
android:id="@+id/gdi_arrow_up"
android:layout_width="27dip"
android:layout_height="27dip"
android:scaleType="fitCenter"
android:layout_marginBottom="-8dip"
android:background="#ff0000"/>
<ImageView
android:id="@+id/gdi_arrow_down"
android:layout_width="27dip"
android:layout_height="27dip"
android:scaleType="fitCenter"
android:layout_marginBottom="-8dip"
android:layout_below="@android:id/list"
android:src="@drawable/list_arrow_down" />
</RelativeLayout>

@ -145,11 +145,8 @@ public class AstridWrapperActivity extends FragmentActivity
if (fragmentLayout != LAYOUT_SINGLE) {
TaskEditActivity editActivity = getTaskEditFragment();
findViewById(R.id.taskedit_fragment_container).setVisibility(View.VISIBLE);
if(fragmentLayout == LAYOUT_DOUBLE) {
findViewById(R.id.filterlist_fragment_container).setVisibility(View.GONE);
}
if (fragmentLayout == LAYOUT_TRIPLE)
findViewById(R.id.taskedit_fragment_container).setVisibility(View.VISIBLE);
if(editActivity == null) {
editActivity = new TaskEditActivity();
@ -157,6 +154,13 @@ public class AstridWrapperActivity extends FragmentActivity
transaction.add(R.id.taskedit_fragment_container, editActivity, TaskEditActivity.TAG_TASKEDIT_FRAGMENT);
transaction.addToBackStack(null);
transaction.commit();
runOnUiThread(new Runnable() {
@Override
public void run() {
// Force the transaction to occur so that we can be guaranteed of the fragment existing if we try to present it
getSupportFragmentManager().executePendingTransactions();
}
});
}
editActivity.save(true);

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

@ -10,16 +10,17 @@ import android.graphics.Rect;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import com.timsu.astrid.R;
public class ListDropdownPopover extends QuickActionWidget {
public class FragmentPopover extends QuickActionWidget {
public ListDropdownPopover(Context context) {
public FragmentPopover(Context context, int layout) {
super(context);
setContentView(R.layout.list_dropdown_popover);
setContentView(layout);
setFocusable(true);
setTouchable(true);
@ -30,6 +31,11 @@ public class ListDropdownPopover extends QuickActionWidget {
contentContainer.addView(content);
}
public void setContent(View content, LayoutParams params) {
FrameLayout contentContainer = (FrameLayout) getContentView().findViewById(R.id.content);
contentContainer.addView(content, params);
}
@Override
protected void populateQuickActions(List<QuickAction> quickActions) {
// Do nothing
Loading…
Cancel
Save