Loading res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ <string name="default_root_uri" translatable="false">content://com.android.providers.downloads.documents/root/downloads</string> <string name="datetime_format_12" translatable="false">MMM dd, yyyy, h:mm a</string> <string name="datetime_format_24" translatable="false">MMM dd, yyyy, H:mm</string> <!-- New features must be added behind a boolean flag prefixed w/ "feature_". Please add them in alphabetical order. Same goes for accessor Loading src/com/android/documentsui/DocsSelectionHelper.java +99 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.support.v7.widget.RecyclerView; import com.android.documentsui.selection.DefaultSelectionHelper; import com.android.documentsui.selection.DefaultSelectionHelper.SelectionMode; import com.android.documentsui.selection.MutableSelection; import com.android.documentsui.selection.Selection; import com.android.documentsui.selection.SelectionHelper; Loading @@ -37,7 +38,10 @@ public final class DocsSelectionHelper extends SelectionHelper { private final DelegateFactory mFactory; private final @SelectionMode int mSelectionMode; private @Nullable SelectionHelper mDelegate; // initialize to a dummy object incase we get some input // event drive calls before we're properly initialized. // See: b/69306667. private SelectionHelper mDelegate = new DummySelectionHelper(); @VisibleForTesting DocsSelectionHelper(DelegateFactory factory, @SelectionMode int mode) { Loading Loading @@ -188,4 +192,98 @@ public final class DocsSelectionHelper extends SelectionHelper { return new DefaultSelectionHelper(mode, adapter, stableIds, canSetState); } } /** * A dummy SelectHelper used by DocsSelectionHelper before a real * SelectionHelper has been initialized by DirectoryFragment. */ private static final class DummySelectionHelper extends SelectionHelper { @Override public void addObserver(SelectionObserver listener) { } @Override public boolean hasSelection() { return false; } @Override public Selection getSelection() { return new MutableSelection(); } @Override public void copySelection(Selection dest) { } @Override public boolean isSelected(String id) { return false; } @VisibleForTesting public void replaceSelection(Iterable<String> ids) { } @Override public void restoreSelection(Selection other) { } @Override public boolean setItemsSelected(Iterable<String> ids, boolean selected) { return false; } @Override public void clearSelection() { } @Override public boolean select(String modelId) { return false; } @Override public boolean deselect(String modelId) { return false; } @Override public void startRange(int pos) { } @Override public void extendRange(int pos) { } @Override public void extendProvisionalRange(int pos) { } @Override public void clearProvisionalSelection() { } @Override public void setProvisionalSelection(Set<String> newSelection) { } @Override public void mergeProvisionalSelection() { } @Override public void endRange() { } @Override public boolean isRangeActive() { return false; } @Override public void anchorRange(int position) { } } } src/com/android/documentsui/inspector/DateUtils.java +13 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ */ package com.android.documentsui.inspector; import android.content.Context; import android.content.res.Resources; import android.text.format.DateFormat; import com.android.documentsui.R; import java.util.Locale; /** Loading @@ -28,9 +33,14 @@ final class DateUtils { * @param date Unix timestamp * @return formatted String of date */ static String formatDate(long date) { String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM dd, yyyy, hh:mm"); static String formatDate(Context context, long date) { Resources res = context.getResources(); int formatRes = DateFormat.is24HourFormat(context) ? R.string.datetime_format_24 : R.string.datetime_format_12; String format = DateFormat.getBestDateTimePattern( Locale.getDefault(), res.getString(formatRes)); return DateFormat.format(format, date).toString(); } } src/com/android/documentsui/inspector/DetailsView.java +3 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,8 @@ public class DetailsView extends TableView implements DetailsDisplay { } if (doc.lastModified > 0) { put(R.string.sort_dimension_date, DateUtils.formatDate(doc.lastModified)); put(R.string.sort_dimension_date, DateUtils.formatDate(this.getContext(), doc.lastModified)); } // We only show summary field when doc is partial (meaning an active download). Loading tests/unit/com/android/documentsui/DocsSelectionHelperTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.documentsui; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.support.test.filters.SmallTest; Loading Loading @@ -71,6 +73,13 @@ public class DocsSelectionHelperTest { mSelectionMgr = new DocsSelectionHelper(mFactory, DefaultSelectionHelper.MODE_MULTIPLE); } @Test public void testCallableBeforeReset() { mSelectionMgr.hasSelection(); assertNotNull(mSelectionMgr.getSelection()); assertFalse(mSelectionMgr.isSelected("poodle")); } @Test public void testReset_CreatesNewInstances() { mSelectionMgr.reset(null, null, null); // nulls are passed to factory. We ignore. Loading Loading
res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ <string name="default_root_uri" translatable="false">content://com.android.providers.downloads.documents/root/downloads</string> <string name="datetime_format_12" translatable="false">MMM dd, yyyy, h:mm a</string> <string name="datetime_format_24" translatable="false">MMM dd, yyyy, H:mm</string> <!-- New features must be added behind a boolean flag prefixed w/ "feature_". Please add them in alphabetical order. Same goes for accessor Loading
src/com/android/documentsui/DocsSelectionHelper.java +99 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.support.v7.widget.RecyclerView; import com.android.documentsui.selection.DefaultSelectionHelper; import com.android.documentsui.selection.DefaultSelectionHelper.SelectionMode; import com.android.documentsui.selection.MutableSelection; import com.android.documentsui.selection.Selection; import com.android.documentsui.selection.SelectionHelper; Loading @@ -37,7 +38,10 @@ public final class DocsSelectionHelper extends SelectionHelper { private final DelegateFactory mFactory; private final @SelectionMode int mSelectionMode; private @Nullable SelectionHelper mDelegate; // initialize to a dummy object incase we get some input // event drive calls before we're properly initialized. // See: b/69306667. private SelectionHelper mDelegate = new DummySelectionHelper(); @VisibleForTesting DocsSelectionHelper(DelegateFactory factory, @SelectionMode int mode) { Loading Loading @@ -188,4 +192,98 @@ public final class DocsSelectionHelper extends SelectionHelper { return new DefaultSelectionHelper(mode, adapter, stableIds, canSetState); } } /** * A dummy SelectHelper used by DocsSelectionHelper before a real * SelectionHelper has been initialized by DirectoryFragment. */ private static final class DummySelectionHelper extends SelectionHelper { @Override public void addObserver(SelectionObserver listener) { } @Override public boolean hasSelection() { return false; } @Override public Selection getSelection() { return new MutableSelection(); } @Override public void copySelection(Selection dest) { } @Override public boolean isSelected(String id) { return false; } @VisibleForTesting public void replaceSelection(Iterable<String> ids) { } @Override public void restoreSelection(Selection other) { } @Override public boolean setItemsSelected(Iterable<String> ids, boolean selected) { return false; } @Override public void clearSelection() { } @Override public boolean select(String modelId) { return false; } @Override public boolean deselect(String modelId) { return false; } @Override public void startRange(int pos) { } @Override public void extendRange(int pos) { } @Override public void extendProvisionalRange(int pos) { } @Override public void clearProvisionalSelection() { } @Override public void setProvisionalSelection(Set<String> newSelection) { } @Override public void mergeProvisionalSelection() { } @Override public void endRange() { } @Override public boolean isRangeActive() { return false; } @Override public void anchorRange(int position) { } } }
src/com/android/documentsui/inspector/DateUtils.java +13 −3 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ */ package com.android.documentsui.inspector; import android.content.Context; import android.content.res.Resources; import android.text.format.DateFormat; import com.android.documentsui.R; import java.util.Locale; /** Loading @@ -28,9 +33,14 @@ final class DateUtils { * @param date Unix timestamp * @return formatted String of date */ static String formatDate(long date) { String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM dd, yyyy, hh:mm"); static String formatDate(Context context, long date) { Resources res = context.getResources(); int formatRes = DateFormat.is24HourFormat(context) ? R.string.datetime_format_24 : R.string.datetime_format_12; String format = DateFormat.getBestDateTimePattern( Locale.getDefault(), res.getString(formatRes)); return DateFormat.format(format, date).toString(); } }
src/com/android/documentsui/inspector/DetailsView.java +3 −2 Original line number Diff line number Diff line Loading @@ -59,7 +59,8 @@ public class DetailsView extends TableView implements DetailsDisplay { } if (doc.lastModified > 0) { put(R.string.sort_dimension_date, DateUtils.formatDate(doc.lastModified)); put(R.string.sort_dimension_date, DateUtils.formatDate(this.getContext(), doc.lastModified)); } // We only show summary field when doc is partial (meaning an active download). Loading
tests/unit/com/android/documentsui/DocsSelectionHelperTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.documentsui; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.support.test.filters.SmallTest; Loading Loading @@ -71,6 +73,13 @@ public class DocsSelectionHelperTest { mSelectionMgr = new DocsSelectionHelper(mFactory, DefaultSelectionHelper.MODE_MULTIPLE); } @Test public void testCallableBeforeReset() { mSelectionMgr.hasSelection(); assertNotNull(mSelectionMgr.getSelection()); assertFalse(mSelectionMgr.isSelected("poodle")); } @Test public void testReset_CreatesNewInstances() { mSelectionMgr.reset(null, null, null); // nulls are passed to factory. We ignore. Loading