Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pictures can be upload directly clicking them from the device's camera. #2097

Merged
merged 13 commits into from
Feb 9, 2018

Conversation

shashvat-kedia
Copy link
Contributor

@shashvat-kedia shashvat-kedia commented Jan 24, 2018

Fix to Issue #2027


BUGS & IMPROVEMENTS

@davigonz
Copy link
Contributor

Hi @SD1998 , thank you for opening this again, using a new branch for a new feature is always the best approach 👍

I've seen that the commit of the android-library (7c7cad7) is not the proper one, please update it to the latest one (0e7fd8e).

From your Android app directory:

cd owncloud-android-library
git checkout 0e7fd8ee8fb1ad082acba8911412571b206ee1f0
cd ..
git add owncloud-android-library
git commit ...
git push ...

@shashvat-kedia
Copy link
Contributor Author

@davigonz Is it the latest one now? (I have just changed it)

@davigonz
Copy link
Contributor

Is it the latest one now? (I have just changed it)

@SD1998 Yes, the library change has just disappeared from the Files changed tab, thanks 👏

@shashvat-kedia
Copy link
Contributor Author

@davigonz Has the QA started?

@@ -82,6 +82,10 @@
<string name="file_list_file">file</string>
<string name="file_list_files">files</string>
<string name="filedetails_select_file">Tap on a file to display additional information.</string>
<string name="upload_owncloud"> Upload to OwnCloud </string>
<string name="upload_bottom_sheet_displayed"> Upload Bottom Sheet Displayed </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resource is not being used, please delete it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am using upload_owncloud

Copy link
Contributor

@davigonz davigonz Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant upload_bottom_sheet_displayed, which you've already deleted.

There's still some space at the beginning and end of Upload to ownCloud in upload_owncloud resource. Do you really need it? If so, please use margin or padding in the xml layout.

@@ -82,6 +82,10 @@
<string name="file_list_file">file</string>
<string name="file_list_files">files</string>
<string name="filedetails_select_file">Tap on a file to display additional information.</string>
<string name="upload_owncloud"> Upload to OwnCloud </string>
<string name="upload_bottom_sheet_displayed"> Upload Bottom Sheet Displayed </string>
<string name="upload_bottom_sheet_collapsed"> Upload Bottom Sheet Collapsed </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, delete it

@@ -176,6 +180,7 @@
<string name="foreign_files_remote_text">"Remote: %1$s"</string>
<string name="upload_query_move_foreign_files">There is not enough space to copy the selected files into the %1$s folder. Would you like to move them instead? </string>
<string name="pass_code_enter_pass_code">Please insert your passcode</string>
<string name="bottom_sheets_layout_behaviour"> android.support.design.widget.BottomSheetBehavior </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used, can be deleted

@@ -205,6 +210,9 @@
<string name="media_rewind_description">Rewind button</string>
<string name="media_play_pause_description">Play or pause button</string>
<string name="media_forward_description">Fast forward button</string>
<string name="button_text_camera"> Camera </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using spaces before and after the value of this resource? If you want to add a margin or padding, please include it in the xml file instead of here.

Copy link
Contributor

@davigonz davigonz Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using button_text_camera resource? Cannot find its use.

@@ -205,6 +210,9 @@
<string name="media_rewind_description">Rewind button</string>
<string name="media_play_pause_description">Play or pause button</string>
<string name="media_forward_description">Fast forward button</string>
<string name="button_text_camera"> Camera </string>
<string name="upload_from_camera_title"> Upload From Camera </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, there are several ones

@@ -205,6 +210,9 @@
<string name="media_rewind_description">Rewind button</string>
<string name="media_play_pause_description">Play or pause button</string>
<string name="media_forward_description">Fast forward button</string>
<string name="button_text_camera"> Camera </string>
<string name="upload_from_camera_title"> Upload From Camera </string>
<string name="capture_button_text"> Capture </string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capture_button_text seems not to be used either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I just saw that. I used it when I was not using bottom sheets and instead using a FAB.


SharedPreferences.Editor appPreferencesEditor = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()).edit();


if (mRadioBtnMoveFiles.isChecked()){
if(requestCode == FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using the condition if(requestCode == FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA){ twice here to set several params, is not possible to use just one and unify all the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I have done that

@davigonz
Copy link
Contributor

Has the QA started?

@SD1998 No, I've just passed what I think is going to be last code review. After that, @jesmrec will start QA.

@shashvat-kedia
Copy link
Contributor Author

@davigonz I will work on this I remember using some of the string resources in Log_OC.d() I will check them again. If I am not using them then I will remove them.
Regarding the last one I think one way to unify the code will be to create another class that extends AsyncTask and execute it when the user selects the upload from camera option from the bottom sheet. But I did not do that in the first place because the new AsyncTask will be very much similar to CheckAvailableSpaceTask class (the part in doInBackground() and onPostExecute()) which will result in much more code duplication hence I used the current approach. Should I add another AsyncTask and not use the if statements?

@davigonz
Copy link
Contributor

davigonz commented Jan 25, 2018

Regarding the last one I think one way to unify the code will be to create another class that extends AsyncTask and execute it when the user selects the upload from camera option from the bottom sheet. But I did not do that in the first place because the new AsyncTask will be very much similar to CheckAvailableSpaceTask class (the part in doInBackground() and onPostExecute()) which will result in much more code duplication hence I used the current approach. Should I add another AsyncTask and not use the if statements?

@SD1998 What I meant is something easier, like this:

screen_shot_2018-01-25_at_15_23_51

@shashvat-kedia
Copy link
Contributor Author

@davigonz Ok I will work on this.

@shashvat-kedia shashvat-kedia force-pushed the Fix-2027-Rebase branch 2 times, most recently from 7d1fd1f to d481dd1 Compare January 27, 2018 07:19
@shashvat-kedia
Copy link
Contributor Author

@davigonz Are there any more changes required?

@davigonz
Copy link
Contributor

davigonz commented Jan 29, 2018

@shashvat-kedia
Copy link
Contributor Author

shashvat-kedia commented Jan 29, 2018

I have done all the changes.

@davigonz
Copy link
Contributor

davigonz commented Jan 30, 2018

@SD1998 Thank you, it looks good to me, changes approved, ready to pass QA @jesmrec

@shashvat-kedia shashvat-kedia force-pushed the Fix-2027-Rebase branch 2 times, most recently from 8e1800e to 27ef6a1 Compare February 1, 2018 13:18
@shashvat-kedia shashvat-kedia mentioned this pull request Feb 1, 2018
3 tasks
@jesmrec
Copy link
Collaborator

jesmrec commented Feb 2, 2018

Starting QA here...

@jesmrec
Copy link
Collaborator

jesmrec commented Feb 2, 2018

IMPROVEMENT (1) [DONE]

When a pic is taken, the name it is upload with is the epoch time of the moment. This is not incorrect, of course, but maybe is more clear to set the calendar date as filename, for example: 2018-02-02-1159.JPG or similar, like the style used for most of the cameras.

what do you think?

@shashvat-kedia
Copy link
Contributor Author

shashvat-kedia commented Feb 2, 2018

@jesmrec I think epoch time will be better as it is possible to take two picture in a minute and upload them. Thus resulting in naming conflicts. For ex. If two pictures are taken at 11:59 then both of them will be named 2018-02-02-1159.JPG.

@jesmrec
Copy link
Collaborator

jesmrec commented Feb 2, 2018

it can be set always the second fraction, i mean 2018-02-02-115934.JPG what do you think @davigonz ?

@davigonz
Copy link
Contributor

davigonz commented Feb 2, 2018

it can be set always the second fraction, i mean 2018-02-02-115934.JPG what do you think @davigonz ?

@jesmrec @SD1998 I would use something like IMG_20180131_185750.jpg , which is the current format used by the default Android camera app to save the taken pictures and the users are used to it.

@jesmrec
Copy link
Collaborator

jesmrec commented Feb 2, 2018

BUG (2) [FIXED]

Steps to reproduce:

  1. Install the app
  2. Try to upload any file (not from camera). The option copy/move (bottom of the view) is set to copy by default
  3. Go back to files view, open FAB and upload file from camera.
  4. Take a pic and accept it -> it is uploaded correctly
  5. Try to upload again a file (not from camera)

Current: Option has switched from copy to move
Expected: Option remains as copy

Tested with Nexus5 v6

@shashvat-kedia
Copy link
Contributor Author

@davigonz @jesmrec This is the current naming format in which the pictures are getting uploaded.

@shashvat-kedia
Copy link
Contributor Author

@jesmrec Bug is beacuse I am moving the files that are uploaded directly from the camera. I will fix this now.

@davigonz
Copy link
Contributor

davigonz commented Feb 6, 2018

In this new layout we can make the files and the upload from camera option to be side by side rather than being one below another.

@SD1998 Even with the layout you propose, If we use PEEK_HEIGHT_AUTO, I think we would continue having the problem described in #2097 (comment) and if we do not use PEEK_HEIGHT_AUTO, it would reappear the problem described in #2097 (comment).

There's likely to be a common solution to show all the options both in landscape and portrait modes.

The problem with bottom sheets in landscape mode seems to be known, have a look at https://stackoverflow.com/questions/41591733/bottom-sheet-landscape-issue , it may be useful for you.

@jesmrec
Copy link
Collaborator

jesmrec commented Feb 7, 2018

@SD1998 do you think is feasible to fix that?

@@ -100,6 +104,11 @@
private OCFile mFile = null;
private FileListListAdapter mAdapter;

private LinearLayout uploadFilesLinearLayout;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These four variables do not need to be declared globally, you can declare it directly in registerFabUploadListeners method, where are going to be used.

});
uploadToTextView.setText(String.format(getResources().getString(R.string.upload_to),getResources().getString(R.string.app_name)));
uploadBottomSheetBehavior = BottomSheetBehavior.from((View) uploadBottomSheet.getParent());
uploadBottomSheetBehavior.setPeekHeight(-1);
Copy link
Contributor

@davigonz davigonz Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've managed to fix #2097 (comment) and #2097 (comment) following the next steps:

  1. Delete line uploadBottomSheetBehavior.setPeekHeight(-1);
  2. Include the next code:
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
    @Override
    public void onShow(DialogInterface dialog) {
        uploadBottomSheetBehavior.setPeekHeight(uploadBottomSheet.getMeasuredHeight());
    }
});

With this code, we wait till the dialog is shown, measure its height and use it to set the height of the bottom sheet. I've tested it with different devices (portrait & landscape) and seems to be working properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davigonz Thanks for the help. I trying to find the value of the height of bottom sheet using ViewTreeObserver class but it did not work out. I will implement the changes.

@davigonz
Copy link
Contributor

davigonz commented Feb 8, 2018

Hi @SD1998, I've managed to fix the problem with the bottom sheet height to give you a hand, please have a look at the changes I requested above.

Besides, please update the camera icon for xxxhdpi as I described in #2097 (comment).

After that, @jesmrec will perform the last tests, we will merge and continue with other interesting features.

Thanks

@shashvat-kedia
Copy link
Contributor Author

@davigonz I have made all the changes and added the xxxhdpi icon

uploadBottomSheetBehavior = BottomSheetBehavior.from((View) uploadBottomSheet.getParent());
uploadBottomSheetBehavior.setPeekHeight(-1);
final BottomSheetBehavior uploadBottomSheetBehavior = BottomSheetBehavior.from((View) uploadBottomSheet.getParent());
uploadBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
Copy link
Contributor

@davigonz davigonz Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need this line, the method below that would be enough to fix the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davigonz Yes I forgot to remove it. Sorry I will remove it now.

@davigonz
Copy link
Contributor

davigonz commented Feb 8, 2018

Thanks @SD1998 , let's start with the last QA round @jesmrec

@jesmrec
Copy link
Collaborator

jesmrec commented Feb 9, 2018

The icon size is correct and now the bottom sheet appears and vanish correctly (checked with three devices in different screen sizes).

Finally, we can approve this

@SD1998 please rebase first, then the branch will be merged

@davigonz
Copy link
Contributor

davigonz commented Feb 9, 2018

Thanks for the QA @jesmrec , I will merge when @SD1998 rebases the branch with master

@shashvat-kedia
Copy link
Contributor Author

@davigonz I have done the rebase.

@davigonz davigonz merged commit 14b4379 into owncloud:master Feb 9, 2018
@davigonz
Copy link
Contributor

davigonz commented Feb 9, 2018

@SD1998 @jesmrec Merged, this feature will be included in the next 2.7.0 release, great work 👍

@shashvat-kedia
Copy link
Contributor Author

@davigonz @jesmrec Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants