Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Update build tools to 26.0.2 and update Dropbox sample to v2 API #155

Merged
merged 4 commits into from Dec 24, 2017

Conversation

mitchyboy9
Copy link
Contributor

Hello,

I wanted to use NoNonesense FilePicker in my project to select directories from Dropbox, but it wouldn't work because Dropbox has discontinued the v1 API used by the samples.

I have re-written the Dropbox sample to use the v2 API and thought I would share it for others to benefit.

The only thing that I'm not sure about, and would appreciate your help with, is the change I made in commit a0349ef, which I did to remove a NullPointerException when I first tried to run the Dropbox sample. I feel like I have missed something and that recyclerView in DropboxFilePickerFragment.java should somehow get automatically assigned. Is there a better way that I could have used to do this?

…xample. I can't understand how the recycler view was ever found - is there some Android magic that has changed, or did the Dropbox example never work (which seems hard to believe)?
… any more and any requests that are made using it fail with an HTTP 400 Bad Request (v1_retired).

I have removed the old Dropbox sdk jar from samples/libs and also deleted the supporting libraries that were required.  The Dropbox sdk is now imported using a Gradle dependency.

Unfortunately, the Dropbox v2 API is large and forced me to enable multiDex.  I have seen people moaning about this to Dropbox on their forum, so hopefully they will do something to shrink the size of the library.
Copy link
Owner

@spacecowboy spacecowboy left a comment

Choose a reason for hiding this comment

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

Thanks again for the PR @mitchyboy9

I've tested it and it seems to work great.

I also had a look at that recyclerview thing you noted. And indeed there was something weird. I've added two inline notes for lines to delete. The second one is the assignment you added but the first is an unecessay file-local recyclerview member. I've must have added this by mistake at some point and it kept working by accident.

The correct member is defined in the parent class here: https://github.com/spacecowboy/NoNonsense-FilePicker/blob/master/library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java#L88

and it is assigned during initialization here: https://github.com/spacecowboy/NoNonsense-FilePicker/blob/master/library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java#L172

I removed the two lines locally and no nullpointer exceptions.

@@ -57,6 +58,7 @@ protected View inflateRootView(LayoutInflater inflater, ViewGroup container) {
View view = inflater.inflate(R.layout.fragment_loading_filepicker, container, false);
// And bind the progress bar
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
recyclerView = (RecyclerView) view.findViewById(android.R.id.list);
Copy link
Owner

Choose a reason for hiding this comment

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

Delete this line.

private final DropboxAPI<AndroidAuthSession> dbApi;
public class DropboxFilePickerFragment extends AbstractFilePickerFragment<Metadata> {
private static final String TAG = "DbxFilePickerFragment";
private final DbxClientV2 dropboxClient;
private ProgressBar progressBar;
private RecyclerView recyclerView;
Copy link
Owner

Choose a reason for hiding this comment

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

Delete this line.

@spacecowboy
Copy link
Owner

And if it's not too much trouble, would you mind adding an entry for build-tools-26.0.2 somewhere here: https://github.com/spacecowboy/NoNonsense-FilePicker/blob/master/.travis.yml#L10 ? (I could do this seperately if you prefer otherwise)

…odules and Travis config.

* Altered Dropbox login logic so that the sample won't get stuck in a loop if the user doesn't authenticate with Dropbox.  Previously, if they cancelled the login process, they would immediately be taken back to Dropbox to log in again...and again!

* Removed the RecyclerView from DropboxFilePickerFragment.java, as it is already declared and instantiated in AbstractFilePickerFragment.java
@mitchyboy9
Copy link
Contributor Author

Thanks very much for your help with the RecyclerView issue. It's working fine for me now as well.

I've updated the Travis build tools (and the Example and Sample modules, so everything is at the same level).

Finally, I made a tweak to the Dropbox login code because, if you didn't authenticate with Dropbox when taken to the app/website to authorise the sample, you would get stuck in a loop where the sample would try to authenticate again...and again until you either killed the app, or did, actually, log in to Dropbox.

@spacecowboy
Copy link
Owner

Excellent. Thanks so much.

@spacecowboy spacecowboy merged commit 72333f8 into spacecowboy:master Dec 24, 2017
@spacecowboy spacecowboy changed the title Update samples to Dropbox v2 API now that v1 API has been discontinued Update build tools to 26.0.2 and update Dropbox sample to v2 API Jan 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants