am bb77d99c: Merge "Directories are always enabled; update assets." into klp-dev
* commit 'bb77d99c257bc4a3371548c4bc8ba7088fa76005': Directories are always enabled; update assets.
|
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.RecentsProvider.StateColumns;
|
||||||
import com.android.documentsui.model.DocumentInfo;
|
import com.android.documentsui.model.DocumentInfo;
|
||||||
import com.android.documentsui.model.RootInfo;
|
import com.android.documentsui.model.RootInfo;
|
||||||
import com.android.internal.util.Predicate;
|
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -95,8 +94,6 @@ public class DirectoryFragment extends Fragment {
|
|||||||
|
|
||||||
private AbsListView mCurrentView;
|
private AbsListView mCurrentView;
|
||||||
|
|
||||||
private Predicate<DocumentInfo> mFilter;
|
|
||||||
|
|
||||||
public static final int TYPE_NORMAL = 1;
|
public static final int TYPE_NORMAL = 1;
|
||||||
public static final int TYPE_SEARCH = 2;
|
public static final int TYPE_SEARCH = 2;
|
||||||
public static final int TYPE_RECENT_OPEN = 3;
|
public static final int TYPE_RECENT_OPEN = 3;
|
||||||
@@ -354,8 +351,6 @@ public class DirectoryFragment extends Fragment {
|
|||||||
private void updateDisplayState() {
|
private void updateDisplayState() {
|
||||||
final State state = getDisplayState(this);
|
final State state = getDisplayState(this);
|
||||||
|
|
||||||
mFilter = new MimePredicate(state.acceptMimes);
|
|
||||||
|
|
||||||
if (mLastMode == state.derivedMode && mLastShowSize == state.showSize) return;
|
if (mLastMode == state.derivedMode && mLastShowSize == state.showSize) return;
|
||||||
mLastMode = state.derivedMode;
|
mLastMode = state.derivedMode;
|
||||||
mLastShowSize = state.showSize;
|
mLastShowSize = state.showSize;
|
||||||
@@ -399,8 +394,10 @@ public class DirectoryFragment extends Fragment {
|
|||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
final Cursor cursor = mAdapter.getItem(position);
|
final Cursor cursor = mAdapter.getItem(position);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
|
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
||||||
if (mFilter.apply(doc)) {
|
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
|
||||||
|
if (isDocumentEnabled(docMimeType, docFlags)) {
|
||||||
|
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
|
||||||
((DocumentsActivity) getActivity()).onDocumentPicked(doc);
|
((DocumentsActivity) getActivity()).onDocumentPicked(doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,11 +476,10 @@ public class DirectoryFragment extends Fragment {
|
|||||||
final Cursor cursor = mAdapter.getItem(position);
|
final Cursor cursor = mAdapter.getItem(position);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
|
||||||
|
final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
|
||||||
// Only valid if non-directory matches filter
|
if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
|
||||||
final State state = getDisplayState(DirectoryFragment.this);
|
valid = isDocumentEnabled(docMimeType, docFlags);
|
||||||
valid = !Document.MIME_TYPE_DIR.equals(docMimeType)
|
}
|
||||||
&& MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
@@ -896,14 +892,7 @@ public class DirectoryFragment extends Fragment {
|
|||||||
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
|
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
|
final boolean enabled = isDocumentEnabled(docMimeType, docFlags);
|
||||||
|| 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
setEnabledRecursive(convertView, true);
|
setEnabledRecursive(convertView, true);
|
||||||
icon.setAlpha(1f);
|
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;
|
package com.android.externalstorage;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.MatrixCursor;
|
import android.database.MatrixCursor;
|
||||||
@@ -166,11 +165,12 @@ public class ExternalStorageProvider extends DocumentsProvider {
|
|||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (file.isDirectory() && file.canWrite()) {
|
|
||||||
flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
|
|
||||||
}
|
|
||||||
if (file.canWrite()) {
|
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;
|
flags |= Document.FLAG_SUPPORTS_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||