Reduce edit screen layout nesting

pull/384/head
Alex Baker 10 years ago
parent 85e1d6e43b
commit 0af798b733

@ -141,6 +141,10 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
commentsController.initialize(model, comments); commentsController.initialize(model, comments);
commentsController.reloadView(); commentsController.reloadView();
for (int i = 0 ; i < TaskEditControlSetFragmentManager.TASK_EDIT_CONTROL_FRAGMENT_ROWS.length - taskEditControlSetFragmentManager.getNumRows() ; i++) {
view.findViewById(TaskEditControlSetFragmentManager.TASK_EDIT_DIVIDER_ROWS[i]).setVisibility(View.GONE);
}
return view; return view;
} }

@ -51,6 +51,19 @@ public class TaskEditControlSetFragmentManager {
R.id.row_10, R.id.row_10,
}; };
public static final int[] TASK_EDIT_DIVIDER_ROWS = new int[] {
R.id.row_divider_10,
R.id.row_divider_9,
R.id.row_divider_8,
R.id.row_divider_7,
R.id.row_divider_6,
R.id.row_divider_5,
R.id.row_divider_4,
R.id.row_divider_3,
R.id.row_divider_2,
R.id.row_divider_1
};
private static final int[] TASK_EDIT_CONTROL_SET_FRAGMENTS = new int[] { private static final int[] TASK_EDIT_CONTROL_SET_FRAGMENTS = new int[] {
EditTitleControlSet.TAG, EditTitleControlSet.TAG,
DeadlineControlSet.TAG, DeadlineControlSet.TAG,
@ -74,8 +87,8 @@ public class TaskEditControlSetFragmentManager {
private final Map<String, Integer> controlSetFragments = new LinkedHashMap<>(); private final Map<String, Integer> controlSetFragments = new LinkedHashMap<>();
private final List<String> displayOrder; private final List<String> displayOrder;
private final String hideAlwaysTrigger;
private final FragmentManager fragmentManager; private final FragmentManager fragmentManager;
private int numRows;
@Inject @Inject
public TaskEditControlSetFragmentManager(Activity activity, Preferences preferences) { public TaskEditControlSetFragmentManager(Activity activity, Preferences preferences) {
@ -83,20 +96,26 @@ public class TaskEditControlSetFragmentManager {
displayOrder.add(0, activity.getString(EditTitleControlSet.TAG)); displayOrder.add(0, activity.getString(EditTitleControlSet.TAG));
displayOrder.add(1, activity.getString(CommentBarFragment.TAG)); displayOrder.add(1, activity.getString(CommentBarFragment.TAG));
fragmentManager = activity.getFragmentManager(); fragmentManager = activity.getFragmentManager();
hideAlwaysTrigger = activity.getString(R.string.TEA_ctrl_hide_section_pref); String hideAlwaysTrigger = activity.getString(R.string.TEA_ctrl_hide_section_pref);
for (numRows = 0 ; numRows < displayOrder.size() ; numRows++) {
if (displayOrder.get(numRows).equals(hideAlwaysTrigger)) {
break;
}
}
for (int resId : TASK_EDIT_CONTROL_SET_FRAGMENTS) { for (int resId : TASK_EDIT_CONTROL_SET_FRAGMENTS) {
controlSetFragments.put(activity.getString(resId), resId); controlSetFragments.put(activity.getString(resId), resId);
} }
} }
public int getNumRows() {
return numRows;
}
public List<TaskEditControlFragment> createNewFragments(boolean isNewTask, Task task) { public List<TaskEditControlFragment> createNewFragments(boolean isNewTask, Task task) {
List<TaskEditControlFragment> taskEditControlFragments = new ArrayList<>(); List<TaskEditControlFragment> taskEditControlFragments = new ArrayList<>();
for (int i = 0; i < displayOrder.size(); i++) { for (int i = 0; i < numRows; i++) {
String item = displayOrder.get(i); String item = displayOrder.get(i);
if (item.equals(hideAlwaysTrigger)) {
break;
}
Integer resId = controlSetFragments.get(item); Integer resId = controlSetFragments.get(item);
if (resId == null) { if (resId == null) {
Timber.e("Unknown task edit control %s", item); Timber.e("Unknown task edit control %s", item);

@ -22,7 +22,7 @@ public abstract class TaskEditControlFragment extends InjectingFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.control_set_template, null); final View view = inflater.inflate(R.layout.control_set_template, null);
LinearLayout content = (LinearLayout) view.findViewById(R.id.content); LinearLayout content = (LinearLayout) view.findViewById(R.id.content);
content.addView(inflater.inflate(getLayout(), null)); inflater.inflate(getLayout(), content);
ImageView icon = (ImageView) view.findViewById(R.id.icon); ImageView icon = (ImageView) view.findViewById(R.id.icon);
icon.setImageResource(getIcon()); icon.setImageResource(getIcon());
ButterKnife.bind(this, view); ButterKnife.bind(this, view);

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

@ -4,12 +4,12 @@
** See the file "LICENSE" for the full license governing this code. ** See the file "LICENSE" for the full license governing this code.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_weight="100"> android:layout_weight="100">

@ -4,7 +4,7 @@
** See the file "LICENSE" for the full license governing this code. ** See the file "LICENSE" for the full license governing this code.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

@ -18,8 +18,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="2dip" android:layout_marginTop="2dip"
android:layout_marginBottom="5dip" android:layout_marginBottom="5dip" />
/>
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -29,7 +28,7 @@
<ListView <ListView
android:id="@+id/existingTags" android:id="@+id/existingTags"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="0dp"
android:layout_marginLeft="3dip" android:layout_marginLeft="3dip"
android:layout_marginRight="3dip" android:layout_marginRight="3dip"
android:layout_weight="100" android:layout_weight="100"

@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/keyline_first" android:paddingLeft="@dimen/keyline_first"
android:paddingStart="@dimen/keyline_first" android:paddingStart="@dimen/keyline_first"
android:paddingRight="@dimen/keyline_first"
android:paddingEnd="@dimen/keyline_first"
android:paddingTop="@dimen/task_edit_drawable_padding_top_bottom"
android:paddingBottom="@dimen/task_edit_drawable_padding_top_bottom"
tools:ignore="RtlSymmetry"> tools:ignore="RtlSymmetry">
<ImageView <ImageView
@ -15,30 +20,8 @@
android:layout_gravity="top" android:layout_gravity="top"
android:tint="?attr/icon_tint" android:tint="?attr/icon_tint"
android:alpha="@dimen/alpha_secondary_text_icons" android:alpha="@dimen/alpha_secondary_text_icons"
android:paddingTop="@dimen/task_edit_drawable_padding_top_bottom"
android:paddingBottom="@dimen/task_edit_drawable_padding_top_bottom"
android:paddingRight="@dimen/keyline_second" android:paddingRight="@dimen/keyline_second"
android:paddingEnd="@dimen/keyline_second" android:paddingEnd="@dimen/keyline_second"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/task_edit_padding_top_bottom"
android:layout_marginTop="@dimen/task_edit_padding_top_bottom">
<LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingRight="@dimen/keyline_first"
android:paddingEnd="@dimen/keyline_first"
tools:ignore="RtlSymmetry" />
<include layout="@layout/task_edit_divider" />
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -27,18 +27,21 @@
style="@style/TextAppearance" /> style="@style/TextAppearance" />
<TextView <TextView
android:id="@+id/estimatedDuration" android:id="@+id/estimatedDuration"
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="right" android:gravity="end"
android:paddingLeft="10dip" android:paddingLeft="10dip"
android:paddingStart="10dp"
android:textColor="?attr/asTextColor" /> android:textColor="?attr/asTextColor" />
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/TEA_Separator" android:id="@+id/TEA_Separator"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="1px" android:layout_height="1px"
android:background="?android:attr/listDivider" /> android:background="?android:attr/listDivider" />
<!-- elapsed time --> <!-- elapsed time -->
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -47,17 +50,19 @@
android:layout_marginRight="10dip" android:layout_marginRight="10dip"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView
<TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/TEA_elapsedDuration_label" android:text="@string/TEA_elapsedDuration_label"
style="@style/TextAppearance" /> style="@style/TextAppearance" />
<TextView <TextView
android:id="@+id/elapsedDuration" android:id="@+id/elapsedDuration"
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="right" android:gravity="end"
android:paddingLeft="10dip" android:paddingLeft="10dip"
android:textColor="?attr/asTextColor" /> android:textColor="?attr/asTextColor" />
</LinearLayout> </LinearLayout>

@ -10,7 +10,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_weight="100" android:layout_weight="100"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/keyline_first" android:paddingLeft="@dimen/keyline_first"

@ -36,51 +36,91 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_1"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_2" android:id="@+id/row_2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_2"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_3" android:id="@+id/row_3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_3"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_4" android:id="@+id/row_4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_4"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_5" android:id="@+id/row_5"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_5"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_6" android:id="@+id/row_6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_6"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_7" android:id="@+id/row_7"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_7"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_8" android:id="@+id/row_8"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_8"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_9" android:id="@+id/row_9"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_9"
style="@style/task_edit_row_divider" />
<FrameLayout <FrameLayout
android:id="@+id/row_10" android:id="@+id/row_10"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<View
android:id="@+id/row_divider_10"
style="@style/task_edit_row_divider" />
<LinearLayout <LinearLayout
android:id="@+id/comments" android:id="@+id/comments"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -2,4 +2,5 @@
<resources> <resources>
<dimen name="keyline_first">24dp</dimen> <dimen name="keyline_first">24dp</dimen>
<dimen name="toolbar_horizontal_padding">12dp</dimen> <dimen name="toolbar_horizontal_padding">12dp</dimen>
<dimen name="keyline_second_absolute">68dp</dimen>
</resources> </resources>

@ -3,6 +3,7 @@
<dimen name="navigation_drawer_width">260dp</dimen> <dimen name="navigation_drawer_width">260dp</dimen>
<dimen name="keyline_first">16dp</dimen> <dimen name="keyline_first">16dp</dimen>
<dimen name="keyline_second">20dp</dimen> <dimen name="keyline_second">20dp</dimen>
<dimen name="keyline_second_absolute">60dp</dimen>
<dimen name="toolbar_horizontal_padding">4dp</dimen> <dimen name="toolbar_horizontal_padding">4dp</dimen>
<dimen name="widget_margin">0dp</dimen> <dimen name="widget_margin">0dp</dimen>

@ -64,6 +64,15 @@
<item name="android:minWidth">1px</item> <item name="android:minWidth">1px</item>
</style> </style>
<style name="task_edit_row_divider">
<item name="android:layout_marginLeft">@dimen/keyline_second_absolute</item>
<item name="android:layout_marginStart">@dimen/keyline_second_absolute</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1px</item>
<item name="android:background">?attr/task_edit_divider</item>
<item name="android:layout_gravity">end|bottom</item>
</style>
<!-- ==================================================== TaskAdapter == --> <!-- ==================================================== TaskAdapter == -->
<style name="task_list_container"/> <style name="task_list_container"/>

Loading…
Cancel
Save