Loading packages/DocumentsUI/res/layout/item_dir_grid.xml 0 → 100644 +62 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="@dimen/grid_item_margin" android:background="@color/item_doc_background" android:elevation="5dp" android:focusable="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:paddingTop="16dp" android:paddingBottom="16dp" android:paddingLeft="12dp" android:paddingRight="12dp"> <ImageView android:src="@drawable/ic_doc_folder" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginEnd="8dp" android:scaleType="centerInside" android:contentDescription="@null"/> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="middle" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textColor="@*android:color/primary_text_default_material_light" /> </LinearLayout> <!-- An overlay that draws the item border when it is focused. --> <View android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@null" android:background="@drawable/item_doc_grid_border" android:duplicateParentState="true" /> </FrameLayout> packages/DocumentsUI/res/layout/item_doc_grid.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/grid_item_margin" android:layout_margin="@dimen/grid_item_margin" android:background="@color/item_doc_background" android:background="@color/item_doc_background" android:elevation="5dp" android:focusable="true"> android:focusable="true"> <!-- Main item thumbnail. Comprised of two overlapping images, the <!-- Main item thumbnail. Comprised of two overlapping images, the Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -964,7 +964,16 @@ public class DirectoryFragment extends Fragment { final State state = getDisplayState(); final State state = getDisplayState(); switch (state.derivedMode) { switch (state.derivedMode) { case MODE_GRID: case MODE_GRID: holder = new GridDocumentHolder(getContext(), parent, mIconHelper, viewType); switch (viewType) { case ITEM_TYPE_DIRECTORY: holder = new GridDirectoryHolder(getContext(), parent); break; case ITEM_TYPE_DOCUMENT: holder = new GridDocumentHolder(getContext(), parent, mIconHelper); break; default: throw new IllegalStateException("Unsupported layout type."); } break; break; case MODE_LIST: case MODE_LIST: holder = new ListDocumentHolder(getContext(), parent, mIconHelper); holder = new ListDocumentHolder(getContext(), parent, mIconHelper); Loading Loading @@ -1031,7 +1040,10 @@ public class DirectoryFragment extends Fragment { @Override @Override public void onModelUpdate(Model model) { public void onModelUpdate(Model model) { mModelIds = Lists.newArrayList(model.getModelIds()); mModelIds = Lists.newArrayList(model.getModelIds()); mDividerPosition = 0; // Start the divider at the end. That way if the code below encounters no documents // (i.e. in a directory containing only directories), the divider is placed at the end // of the list, as expected. mDividerPosition = mModelIds.size(); // Walk down the list of IDs till we encounter something that's not a directory, and // Walk down the list of IDs till we encounter something that's not a directory, and // insert a whitespace element - this introduces a visual break in the grid between // insert a whitespace element - this introduces a visual break in the grid between Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java +3 −6 Original line number Original line Diff line number Diff line Loading @@ -40,16 +40,15 @@ public abstract class DocumentHolder final int mDefaultItemColor; final int mDefaultItemColor; final boolean mAlwaysShowSummary; final boolean mAlwaysShowSummary; final Context mContext; final Context mContext; final IconHelper mIconHelper; private ListDocumentHolder.ClickListener mClickListener; private ListDocumentHolder.ClickListener mClickListener; private View.OnKeyListener mKeyListener; private View.OnKeyListener mKeyListener; public DocumentHolder(Context context, ViewGroup parent, int layout, IconHelper iconHelper) { public DocumentHolder(Context context, ViewGroup parent, int layout) { this(context, inflateLayout(context, parent, layout), iconHelper); this(context, inflateLayout(context, parent, layout)); } } public DocumentHolder(Context context, View item, IconHelper iconHelper) { public DocumentHolder(Context context, View item) { super(item); super(item); itemView.setOnKeyListener(this); itemView.setOnKeyListener(this); Loading @@ -59,8 +58,6 @@ public abstract class DocumentHolder mDefaultItemColor = context.getColor(R.color.item_doc_background); mDefaultItemColor = context.getColor(R.color.item_doc_background); mSelectedItemColor = context.getColor(R.color.item_doc_background_selected); mSelectedItemColor = context.getColor(R.color.item_doc_background_selected); mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary); mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary); mIconHelper = iconHelper; } } /** /** Loading packages/DocumentsUI/src/com/android/documentsui/dirlist/EmptyDocumentHolder.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.documentsui.State; final class EmptyDocumentHolder extends DocumentHolder { final class EmptyDocumentHolder extends DocumentHolder { public EmptyDocumentHolder(Context context) { public EmptyDocumentHolder(Context context) { super(context, new View(context), null); super(context, new View(context)); itemView.setVisibility(View.GONE); itemView.setVisibility(View.GONE); } } Loading Loading
packages/DocumentsUI/res/layout/item_dir_grid.xml 0 → 100644 +62 −0 Original line number Original line Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="@dimen/grid_item_margin" android:background="@color/item_doc_background" android:elevation="5dp" android:focusable="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:paddingTop="16dp" android:paddingBottom="16dp" android:paddingLeft="12dp" android:paddingRight="12dp"> <ImageView android:src="@drawable/ic_doc_folder" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginEnd="8dp" android:scaleType="centerInside" android:contentDescription="@null"/> <TextView android:id="@android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="middle" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textColor="@*android:color/primary_text_default_material_light" /> </LinearLayout> <!-- An overlay that draws the item border when it is focused. --> <View android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@null" android:background="@drawable/item_doc_grid_border" android:duplicateParentState="true" /> </FrameLayout>
packages/DocumentsUI/res/layout/item_doc_grid.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/grid_item_margin" android:layout_margin="@dimen/grid_item_margin" android:background="@color/item_doc_background" android:background="@color/item_doc_background" android:elevation="5dp" android:focusable="true"> android:focusable="true"> <!-- Main item thumbnail. Comprised of two overlapping images, the <!-- Main item thumbnail. Comprised of two overlapping images, the Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -964,7 +964,16 @@ public class DirectoryFragment extends Fragment { final State state = getDisplayState(); final State state = getDisplayState(); switch (state.derivedMode) { switch (state.derivedMode) { case MODE_GRID: case MODE_GRID: holder = new GridDocumentHolder(getContext(), parent, mIconHelper, viewType); switch (viewType) { case ITEM_TYPE_DIRECTORY: holder = new GridDirectoryHolder(getContext(), parent); break; case ITEM_TYPE_DOCUMENT: holder = new GridDocumentHolder(getContext(), parent, mIconHelper); break; default: throw new IllegalStateException("Unsupported layout type."); } break; break; case MODE_LIST: case MODE_LIST: holder = new ListDocumentHolder(getContext(), parent, mIconHelper); holder = new ListDocumentHolder(getContext(), parent, mIconHelper); Loading Loading @@ -1031,7 +1040,10 @@ public class DirectoryFragment extends Fragment { @Override @Override public void onModelUpdate(Model model) { public void onModelUpdate(Model model) { mModelIds = Lists.newArrayList(model.getModelIds()); mModelIds = Lists.newArrayList(model.getModelIds()); mDividerPosition = 0; // Start the divider at the end. That way if the code below encounters no documents // (i.e. in a directory containing only directories), the divider is placed at the end // of the list, as expected. mDividerPosition = mModelIds.size(); // Walk down the list of IDs till we encounter something that's not a directory, and // Walk down the list of IDs till we encounter something that's not a directory, and // insert a whitespace element - this introduces a visual break in the grid between // insert a whitespace element - this introduces a visual break in the grid between Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/DocumentHolder.java +3 −6 Original line number Original line Diff line number Diff line Loading @@ -40,16 +40,15 @@ public abstract class DocumentHolder final int mDefaultItemColor; final int mDefaultItemColor; final boolean mAlwaysShowSummary; final boolean mAlwaysShowSummary; final Context mContext; final Context mContext; final IconHelper mIconHelper; private ListDocumentHolder.ClickListener mClickListener; private ListDocumentHolder.ClickListener mClickListener; private View.OnKeyListener mKeyListener; private View.OnKeyListener mKeyListener; public DocumentHolder(Context context, ViewGroup parent, int layout, IconHelper iconHelper) { public DocumentHolder(Context context, ViewGroup parent, int layout) { this(context, inflateLayout(context, parent, layout), iconHelper); this(context, inflateLayout(context, parent, layout)); } } public DocumentHolder(Context context, View item, IconHelper iconHelper) { public DocumentHolder(Context context, View item) { super(item); super(item); itemView.setOnKeyListener(this); itemView.setOnKeyListener(this); Loading @@ -59,8 +58,6 @@ public abstract class DocumentHolder mDefaultItemColor = context.getColor(R.color.item_doc_background); mDefaultItemColor = context.getColor(R.color.item_doc_background); mSelectedItemColor = context.getColor(R.color.item_doc_background_selected); mSelectedItemColor = context.getColor(R.color.item_doc_background_selected); mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary); mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary); mIconHelper = iconHelper; } } /** /** Loading
packages/DocumentsUI/src/com/android/documentsui/dirlist/EmptyDocumentHolder.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ import com.android.documentsui.State; final class EmptyDocumentHolder extends DocumentHolder { final class EmptyDocumentHolder extends DocumentHolder { public EmptyDocumentHolder(Context context) { public EmptyDocumentHolder(Context context) { super(context, new View(context), null); super(context, new View(context)); itemView.setVisibility(View.GONE); itemView.setVisibility(View.GONE); } } Loading