-
Notifications
You must be signed in to change notification settings - Fork 44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the ton of comments, most should be easy fixes!
@@ -39,6 +39,13 @@ public void fileInList(String filename) { | |||
)).check(matches(isDisplayed())); | |||
} | |||
|
|||
public void numOfItemsLabel(String numOfItemsLabel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename this to fileInfoInList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -105,7 +105,7 @@ public View getView(int position, View convertView, ViewGroup parent) { | |||
holder.primaryInfo.setText(item.getName()); | |||
holder.secondaryInfo.setText(item.getFormattedModificationDate(convertView.getContext())); | |||
// Hide directories' size as it's irrelevant if we can't recursively find it. | |||
holder.tertiaryInfo.setText(item.getFile().isDirectory()? "" : item.getFormattedSize( | |||
holder.tertiaryInfo.setText(item.getFile().isDirectory() ? item.getNumberOfItems(convertView.getContext()) : item.getFormattedSize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be extracted to FileHolder#getSizeInfo(Context ctx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -41,7 +41,7 @@ void bind(String filePath, OnItemClickListener listener) { | |||
|
|||
primaryInfo.setText(item.getName()); | |||
secondaryInfo.setText(item.getFormattedModificationDate(context)); | |||
tertiaryInfo.setText(isDirectory ? "" : item.getFormattedSize(context, false)); | |||
tertiaryInfo.setText(isDirectory ? item.getNumberOfItems(context) : item.getFormattedSize(context, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used here too. Ideally getNumberOfItems
and getFormattedSize
will now be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -32,9 +33,12 @@ | |||
import java.io.File; | |||
|
|||
public class FileHolder implements Parcelable, Comparable<FileHolder> { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this space :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
int numOfDirectoryItems = mFile.listFiles().length; | ||
|
||
if (numOfDirectoryItems == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should all be handled by a single plural. This will also force a single point of return for the happy case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@veniosg Plurals in English are a hard thing. Zero is not treated as a special case in English especially. Check this for example https://stackoverflow.com/questions/5651902/android-plurals-treatment-of-zero! Maybe I can check the current configuration or locale and only do it in English.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh of course, good catch! In that case, it's acceptable to keep 0 items
in the zero case in English to let the system handle plural localisation. This would involve duplicating the value of the many_items resource, but OneSky is smart enough to handle that so don't worry.
app/src/main/res/values/plurals.xml
Outdated
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<plurals name="num_of_directory_items"> | ||
<item quantity="one">1 item</item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should still be %1$s item
so it's properly localised if need be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -0,0 +1,7 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this file but point to strings in strings.xml. If it's allowed, this should be marked as translatable=false
.
e.g. <item quantity="zero">@string/no_items</item>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
private final File oneItemContainerDir = new File(testDirectoryWithOneItem, "oneItemContainerDir"); | ||
private final File multipleItemsContainerDir = new File(testDirectoryWithMultipleItems, "multipleItemsContainerDir"); | ||
|
||
private File oneFile = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make final and initialize the same way as the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also name these three something more consistent like countTestFile1/2/3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
private final File testDirectoryWithOneItem = new File(sdCardDir, "testDirWithOneItem"); | ||
private final File testDirectoryWithMultipleItems = new File(sdCardDir, "testDirWithMultipleItems"); | ||
|
||
private final File zeroItemsContainerDir = new File(testDirectoryWithZeroItems, "zeroItemsContainerDir"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference with the files above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -38,6 +40,17 @@ | |||
private final File testChildDirectory = new File(testDirectory, "testChildDir"); | |||
private final File testCopyDestination = new File(testDirectory, "testCopyDestination"); | |||
private final File testChildFile = new File(testDirectory, "testChildFile"); | |||
private final File testDirectoryWithZeroItems = new File(sdCardDir, "testDirWithZeroItems"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create these under testDirectory. That way you need nothing more in tearDown, everything should be cleaned up by cleanDirectory(testDirectory)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -143,7 +143,7 @@ protected void onPostExecute(String result) { | |||
|
|||
@Override | |||
protected String doInBackground(Void... params) { | |||
return mFileHolder.getFormattedSize(getActivity(), true); | |||
return mFileHolder.getSizeInfo(getActivity(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this will break the details Dialog. We should still use getFormattedSize(ctx, true)
here.
return Formatter.formatFileSize(c, getSizeInBytes(recursive)); | ||
} | ||
|
||
private String getNumberOfItems(@NonNull Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to getFormattedNumberOfItems
for consistency
Update strings, names, scopes Fix details dialog Fix test crash
Any update on this? I'd love to include it in 1.5 :) |
@veniosg Sorry is there a pending thing on this? |
AFAIK the new test still doesn't pass. That should be all though |
@veniosg ok will check it when I got some free time! |
Thanks!
…On Tue, 19 Dec 2017, 8:47 am Pavlos-Petros Tournaris, < ***@***.***> wrote:
@veniosg <https://github.com/veniosg> ok will check it when I got some
free time!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#83 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABmcZKj6ODohtRJEOJeRE9EcGevSGBNeks5tB3gKgaJpZM4Q9fNX>
.
|
I guess it can be closed! |
It was very close to being completed. Feel free to reopen if you're keen to fix the test and get it merged :) |
Ohh thought it was fixed... i guess i can find some time to fix it then! |
Resolves #79
Added number of items label in directories showing the number of contained files:
No items
when directory has 0 items1 item
when directory has 1 item# items
when directory has more itemsThese should also be translated I guess! Leaving this up to you to handle the translations @veniosg :)