diff options
Diffstat (limited to 'packages/DocumentsUI/src/com')
4 files changed, 48 insertions, 13 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index ba464f7..e594437 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -214,6 +214,12 @@ public class DirectoryFragment extends Fragment { updateDisplayState(); } + @Override + public void onStart() { + super.onStart(); + updateDisplayState(); + } + public void updateDisplayState() { final State state = getDisplayState(this); @@ -541,7 +547,7 @@ public class DirectoryFragment extends Fragment { final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon); final TextView title = (TextView) convertView.findViewById(android.R.id.title); - final View summaryGrid = convertView.findViewById(R.id.summary_grid); + final View line2 = convertView.findViewById(R.id.line2); final ImageView icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); final TextView summary = (TextView) convertView.findViewById(android.R.id.summary); final TextView date = (TextView) convertView.findViewById(R.id.date); @@ -571,31 +577,32 @@ public class DirectoryFragment extends Fragment { title.setText(docDisplayName); + boolean hasLine2 = false; + if (mType == TYPE_RECENT_OPEN) { final RootInfo root = roots.getRoot(docAuthority, docRootId); icon1.setVisibility(View.VISIBLE); icon1.setImageDrawable(root.loadIcon(context)); summary.setText(root.getDirectoryString()); summary.setVisibility(View.VISIBLE); + summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END); + hasLine2 = true; } else { icon1.setVisibility(View.GONE); if (docSummary != null) { summary.setText(docSummary); summary.setVisibility(View.VISIBLE); + hasLine2 = true; } else { summary.setVisibility(View.INVISIBLE); } } - if (summaryGrid != null) { - summaryGrid.setVisibility( - (summary.getVisibility() == View.VISIBLE) ? View.VISIBLE : View.GONE); - } - if (docLastModified == -1) { date.setText(null); } else { date.setText(formatTime(context, docLastModified)); + hasLine2 = true; } if (state.showSize) { @@ -604,11 +611,14 @@ public class DirectoryFragment extends Fragment { size.setText(null); } else { size.setText(Formatter.formatFileSize(context, docSize)); + hasLine2 = true; } } else { size.setVisibility(View.GONE); } + line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE); + return convertView; } diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index e1f2606..38b2ee8 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -53,6 +53,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; +import android.widget.ImageView; import android.widget.SearchView; import android.widget.SearchView.OnCloseListener; import android.widget.SearchView.OnQueryTextListener; @@ -481,6 +482,8 @@ public class DocumentsActivity extends Activity { title.setText(doc.displayName); } + // No padding when shown in actionbar + convertView.setPadding(0, 0, 0, 0); return convertView; } @@ -488,17 +491,20 @@ public class DocumentsActivity extends Activity { public View getDropDownView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()) - .inflate(android.R.layout.simple_dropdown_item_1line, parent, false); + .inflate(R.layout.item_title, parent, false); } - final TextView text1 = (TextView) convertView.findViewById(android.R.id.text1); + final ImageView subdir = (ImageView) convertView.findViewById(R.id.subdir); + final TextView title = (TextView) convertView.findViewById(android.R.id.title); final DocumentInfo doc = getItem(position); if (position == 0) { final RootInfo root = getCurrentRoot(); - text1.setText(root.title); + title.setText(root.title); + subdir.setVisibility(View.GONE); } else { - text1.setText(doc.displayName); + title.setText(doc.displayName); + subdir.setVisibility(View.VISIBLE); } return convertView; @@ -566,6 +572,11 @@ public class DocumentsActivity extends Activity { } } + final RootsFragment roots = RootsFragment.get(fm); + if (roots != null) { + roots.onCurrentRootChanged(); + } + updateActionBar(); invalidateOptionsMenu(); dumpStack(); diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java index fd7293d..461c415 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java @@ -181,7 +181,6 @@ public class RecentsCreateFragment extends Fragment { final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon); final TextView title = (TextView) convertView.findViewById(android.R.id.title); - final View summaryList = convertView.findViewById(R.id.summary_list); final DocumentStack stack = getItem(position); final RootInfo root = stack.getRoot(roots); @@ -197,8 +196,6 @@ public class RecentsCreateFragment extends Fragment { title.setText(builder.toString()); title.setEllipsize(TruncateAt.MIDDLE); - summaryList.setVisibility(View.GONE); - return convertView; } diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java index ef3a31d..efb972d 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java @@ -40,6 +40,7 @@ import com.android.documentsui.DocumentsActivity.State; import com.android.documentsui.SectionedListAdapter.SectionAdapter; import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.RootInfo; +import com.android.internal.util.Objects; import java.util.Comparator; import java.util.List; @@ -78,6 +79,7 @@ public class RootsFragment extends Fragment { final View view = inflater.inflate(R.layout.fragment_roots, container, false); mList = (ListView) view.findViewById(android.R.id.list); mList.setOnItemClickListener(mItemListener); + mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); return view; } @@ -100,6 +102,21 @@ public class RootsFragment extends Fragment { mAdapter = new SectionedRootsAdapter(context, matchingRoots, includeApps); mList.setAdapter(mAdapter); + + onCurrentRootChanged(); + } + + public void onCurrentRootChanged() { + if (mAdapter == null) return; + + final RootInfo root = ((DocumentsActivity) getActivity()).getCurrentRoot(); + for (int i = 0; i < mAdapter.getCount(); i++) { + final Object item = mAdapter.getItem(i); + if (Objects.equal(item, root)) { + mList.setItemChecked(i, true); + return; + } + } } private OnItemClickListener mItemListener = new OnItemClickListener() { |