Merge "Directories are always enabled; update assets." into klp-dev
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 659 B After Width: | Height: | Size: 574 B |
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 508 B |
|
Before Width: | Height: | Size: 506 B After Width: | Height: | Size: 409 B |
|
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 583 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 268 B |
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 373 B |
@@ -77,7 +77,6 @@ import com.android.documentsui.DocumentsActivity.State;
|
||||
import com.android.documentsui.RecentsProvider.StateColumns;
|
||||
import com.android.documentsui.model.DocumentInfo;
|
||||
import com.android.documentsui.model.RootInfo;
|
||||
import com.android.internal.util.Predicate;
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -95,8 +94,6 @@ public class DirectoryFragment extends Fragment {
|
||||
|
||||
private AbsListView mCurrentView;
|
||||
|
||||
private Predicate<DocumentInfo> mFilter;
|
||||
|
||||
public static final int TYPE_NORMAL = 1;
|
||||
public static final int TYPE_SEARCH = 2;
|
||||
public static final int TYPE_RECENT_OPEN = 3;
|
||||
@@ -354,8 +351,6 @@ public class DirectoryFragment extends Fragment {
|
||||
private void updateDisplayState() {
|
||||
final State state = getDisplayState(this);
|
||||
|
||||
mFilter = new MimePredicate(state.acceptMimes);
|
||||
|
||||
if (mLastMode == state.derivedMode && mLastShowSize == state.showSize) return;
|
||||
mLastMode = state.derivedMode;
|
||||
mLastShowSize = state.showSize;
|
||||
@@ -399,8 +394,10 @@ public class DirectoryFragment extends Fragment {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final Cursor cursor = mAdapter.getItem(position);
|
||||
if (cursor != null) {
|
||||
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
|
||||
if (mFilter.apply(doc)) {
|
||||
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
||||
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
|
||||
if (isDocumentEnabled(docMimeType, docFlags)) {
|
||||
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
|
||||
((DocumentsActivity) getActivity()).onDocumentPicked(doc);
|
||||
}
|
||||
}
|
||||
@@ -479,11 +476,10 @@ public class DirectoryFragment extends Fragment {
|
||||
final Cursor cursor = mAdapter.getItem(position);
|
||||
if (cursor != null) {
|
||||
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
||||
|
||||
// Only valid if non-directory matches filter
|
||||
final State state = getDisplayState(DirectoryFragment.this);
|
||||
valid = !Document.MIME_TYPE_DIR.equals(docMimeType)
|
||||
&& MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
||||
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
|
||||
if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
|
||||
valid = isDocumentEnabled(docMimeType, docFlags);
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
@@ -896,14 +892,7 @@ public class DirectoryFragment extends Fragment {
|
||||
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
|
||||
|| MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
||||
|
||||
// Read-only files aren't actually enabled when creating
|
||||
if (state.action == ACTION_CREATE && (docFlags & Document.FLAG_SUPPORTS_WRITE) == 0) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
final boolean enabled = isDocumentEnabled(docMimeType, docFlags);
|
||||
if (enabled) {
|
||||
setEnabledRecursive(convertView, true);
|
||||
icon.setAlpha(1f);
|
||||
@@ -1067,4 +1056,20 @@ public class DirectoryFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDocumentEnabled(String docMimeType, int docFlags) {
|
||||
final State state = getDisplayState(DirectoryFragment.this);
|
||||
|
||||
// Read-only files are disabled when creating
|
||||
if (state.action == ACTION_CREATE && (docFlags & Document.FLAG_SUPPORTS_WRITE) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Directories are always enabled
|
||||
if (Document.MIME_TYPE_DIR.equals(docMimeType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.externalstorage;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
@@ -166,11 +165,12 @@ public class ExternalStorageProvider extends DocumentsProvider {
|
||||
|
||||
int flags = 0;
|
||||
|
||||
if (file.isDirectory() && file.canWrite()) {
|
||||
flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
|
||||
}
|
||||
if (file.canWrite()) {
|
||||
flags |= Document.FLAG_SUPPORTS_WRITE;
|
||||
if (file.isDirectory()) {
|
||||
flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
|
||||
} else {
|
||||
flags |= Document.FLAG_SUPPORTS_WRITE;
|
||||
}
|
||||
flags |= Document.FLAG_SUPPORTS_DELETE;
|
||||
}
|
||||
|
||||
|
||||