Show and hide quick add controls with quick add focus

pull/14/head
Sam Bosley 13 years ago
parent 207f33685f
commit 69d2f64800

@ -4,6 +4,9 @@
android:id="@+id/taskListParent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
style="@style/Content"
android:orientation="vertical">
@ -26,24 +29,33 @@
android:orientation="vertical"
style="@style/Content">
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="?attr/asSeparatorBackground"/>
<LinearLayout
android:id="@+id/taskListQuickaddControls"
<LinearLayout
android:id="@+id/taskListQuickaddControlsContainer"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal">
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_height="fill_parent"
android:layout_width="1px"
android:background="?attr/asSeparatorBackground"/>
</LinearLayout>
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="?attr/asSeparatorBackground"/>
<LinearLayout
android:id="@+id/taskListQuickaddControls"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal">
<View
android:layout_height="fill_parent"
android:layout_width="1px"
android:background="?attr/asSeparatorBackground"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"

@ -41,10 +41,13 @@ import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
@ -227,6 +230,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
private ImageButton voiceAddButton;
private ImageButton quickAddButton;
private EditText quickAddBox;
private LinearLayout quickAddControls;
private View quickAddControlsContainer;
private Timer backgroundTimer;
private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<SyncAction>();
private boolean isFilter;
@ -519,6 +524,16 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
}
});
getListView().setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
quickAddBox.clearFocus();
return false;
}
});
quickAddControls = (LinearLayout) getView().findViewById(R.id.taskListQuickaddControls);
quickAddControlsContainer = getView().findViewById(R.id.taskListQuickaddControlsContainer);
setUpQuickAddControlSets();
// set listener for pressing enter in quick-add box
@ -539,6 +554,13 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
}
});
quickAddBox.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
quickAddControlsContainer.setVisibility(hasFocus ? View.VISIBLE : View.GONE);
}
});
quickAddButton = ((ImageButton) getView().findViewById(
R.id.quickAddButton));
@ -637,9 +659,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
resetControlSets();
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f);
LinearLayout container = (LinearLayout) getView().findViewById(R.id.taskListQuickaddControls);
container.addView(peopleControl.getDisplayView(), 0, lp);
container.addView(deadlineControl.getDisplayView(), 2, lp);
quickAddControls.addView(peopleControl.getDisplayView(), 0, lp);
quickAddControls.addView(deadlineControl.getDisplayView(), 2, lp);
}
private void resetControlSets() {

Loading…
Cancel
Save