Code Monkey home page Code Monkey logo

filestack-android's Introduction

Filestack Android SDK

Android file uploader for Filestack. Upload local files or select from 10 different cloud sources. Uploads from cloud sources transfer cloud to cloud, avoiding large mobile uploads. Supports Amazon Drive, Box, Dropbox, Facebook, GitHub, Gmail, Google Drive, Google Photos, Instagram, and OneDrive.

Install

implementation 'com.filestack:filestack-android:6.0.0'

Tester and Samples

To quickly test out the SDK you can clone this repo and build the development app (located in the tester directory). It contains settings UI to customize the picker and set credentials, no code changes necessary. You can also build one of the sample apps (located in the samples directory). The tester app is setup as a module of this project but the sample apps are setup as independent projects.

Setup

Add file provider for camera source

To enable users to take photos and videos within the picker, a file provider must be defined for the application to avoid sending "file://" URI's to the camera app. Failure to define a file provider will throw a FileUriExposedException on Android Nougat and above. See the google documentation for more information.

Add a tag to your AndroidManifest.xml:

<provider
    android:name="android.support.v4.content.FileProvider"
    <!-- Change the authority to include your package name. -->
    android:authorities="com.filestack.android.demo.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

file_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="pictures" path="Android/data/com.filestack.android.demo/files/Pictures" />
    <external-path name="movies" path="Android/data/com.filestack.android.demo/files/Movies" />
</paths>

The "pictures" and "movies" names are expected to be defined.

Upload files

Use FilestackPicker - new way

FilestackPicker.Builder class has been introduced to simplify construction of Intents to run FsActivity.

FilestackPicker picker = new FilestackPicker.Builder()
                    .config(...)
                    .storageOptions(...)
                    .config(...)
                    .autoUploadEnabled(...)                    
                    .sources(...)
                    .mimeTypes(...)
                    .multipleFilesSelectionEnabled(...)
                    .displayVersionInformation(...)
                    .build();
                    
picker.launch(activity); //use an Activity instance to launch a picker                                                          

Receive activity results - new way

FsActivity returns immediately once a user selects files. The returned response will always be of List<Selections> type. Receive the response in the calling activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (FilestackPicker.canReadResult(requestCode, resultCode)) {
        Log.i(TAG, "received filestack selections");
        List<Selection> selections = FilestackPicker.getSelectedFiles(data);
        for (int i = 0; i < selections.size(); i++) {
            Selection selection = selections.get(i);
            String msg = String.format(locale, "selection %d: %s", i, selection.getName());
            Log.i(TAG, msg);
        }
    }    
}

Launch activity - old way

// Create an intent to launch FsActivity
Intent intent = new Intent(this, FsActivity.class);

// Create a config object with your account settings
// Using security (policy and signature) is optional
Config config = new Config("API_KEY", "RETURN_URL", "POLICY", "SIGNATURE");
intent.putExtra(FsConstants.EXTRA_CONFIG, config);

// Setting storage options is also optional
// We'll default to Filestack S3 if unset
// The Filename and MIME type options are ignored and overridden
StorageOptions storeOpts = new StorageOptions.Builder()
    .location("gcs")
    .container("android-uploads")
    .build();
intent.putExtra(FsConstants.EXTRA_STORE_OPTS, storeOpts);

// To manually handle uploading, set auto upload to false
// You can upload the user's selections yourself with the Client class
intent.putExtra(FsConstants.EXTRA_AUTO_UPLOAD, false);

// To customize the sources list, pass in a list of constants
// The sources will appear in the order you add them to the list
// Defaults to Camera, Device, Google Drive, Facebook, Instagram, and Dropbox
ArrayList<String> sources = new ArrayList<>();
sources.add(Sources.CAMERA);
sources.add(Sources.DEVICE);
sources.add(Sources.GOOGLE_DRIVE);
sources.add(Sources.GITHUB);
intent.putExtra(FsConstants.EXTRA_SOURCES, sources);

// Restrict the types of files that can be uploaded
// Defaults to allowing all
String[] mimeTypes = {"application/pdf", "image/*", "video/*"};
intent.putExtra(FsConstants.EXTRA_MIME_TYPES, mimeTypes);

// Start the activity
startActivityForResult(intent, REQUEST_FILESTACK);

Receive activity results - old way

FsActivity returns immediately once a user selects files. The returned response will always be an ArrayList of Selection objects. Receive the response in the calling activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_FILESTACK && resultCode == RESULT_OK) {
        Log.i(TAG, "received filestack selections");
        String key = FsConstants.EXTRA_SELECTION_LIST;
        ArrayList<Selection> selections = data.getParcelableArrayListExtra(key);
        for (int i = 0; i < selections.size(); i++) {
            Selection selection = selections.get(i);
            String msg = String.format(locale, "selection %d: %s", i, selection.getName());
            Log.i(TAG, msg);
        }
    }
}

Receive upload status broadcasts

Because the actual uploading occurs in a background service, a BroadcastReceiver needs to be registered in order to get a status and resultant FileLink for each selected file. When the picker returns to onActivityResult() an ArrayList of Selection objects will be received. When an intent message is received in the registered BroadcastReceiver, a status string, a Selection (matching
one in the list), and a FileLink (if the upload succeeded) will be received. As the upload progresses, the background service will also put up notifications about its ongoing status.

UploadStatusReceiver.java:

public class UploadStatusReceiver extends BroadcastReceiver {
    private static final String TAG = "UploadStatusReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Locale locale = Locale.getDefault();
        String status = intent.getStringExtra(FsConstants.EXTRA_STATUS);
        Selection selection = intent.getParcelableExtra(FsConstants.EXTRA_SELECTION);
        FileLink fileLink = (FileLink) intent.getSerializableExtra(FsConstants.EXTRA_FILE_LINK);

        String name = selection.getName();
        String handle = fileLink != null ? fileLink.getHandle() : "n/a";
        String msg = String.format(locale, "upload %s: %s (%s)", status, name, handle);
        Log.i(TAG, msg);
    }
}

Register the receiver in the calling activity's onCreate():

// Be careful to avoid registering multiple receiver instances
if (savedInstanceState == null) {
    IntentFilter intentFilter = new IntentFilter(FsConstants.BROADCAST_UPLOAD);
    UploadStatusReceiver receiver = new UploadStatusReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, intentFilter);
}

Theming

Filestack Android SDK provides a theming mechanism for Filestack Picker screen.

Setting a theme requires passing a Theme to Filestack.Builder#theme(Theme) method call. Theme objects can be constructed with a Theme.Builder instance. If theme is not set, a default one will be used.

Native UI

At present this SDK doesn't offer many customization options, but the Java SDK can be used to build a native UI. This SDK adds UI and convenience on top of the Java SDK.

Proguard

Filestack Android SDK definies its own consumerProguardRule to ensure that no additional configuration on consumer side is required.

Deployment

This is for Filestack devs. Deployments are made to Bintray. You must have an account that's been added to the Filestack organization to deploy. Also make sure to follow general Filestack release guidelines. "BINTRAY_USER" and "BINTRAY_API_KEY" environment variables are required. To run:

export BINTRAY_USER=''
export BINTRAY_API_KEY=''
./gradlew bintrayUpload

filestack-android's People

Contributors

brettcvz avatar carlosfromnewyork avatar exviva avatar firezenk avatar fngr avatar hemanth-3 avatar imran0101 avatar jahudzik avatar jrejaud avatar krschultz avatar kyuss avatar lifedemons avatar liyanchang avatar maciejwitowski avatar marcinqualaroo avatar marcors avatar marcosteixeira avatar ratgabi avatar raulacevedo avatar scana avatar sethk4783 avatar shawnmaten avatar sleeplessbyte avatar tageorgiou avatar thesociableme avatar thinkh avatar velveteer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

filestack-android's Issues

Target SDK 17

Is Android 4.2 really the highest version this library has been tested against? If not, should be updated.

Clearing Filepicker cache on logout

How do we go about clearing the Filepicker cache?

The use case would be that if someone logs out of our app and logs in under another account, they should not be logged in to any Cloud accounts in Filepicker.

Update README for proguard obsfucation rules

We were having crashes with the Filepicker SDK. Turns out that we needed to add:

-keep class retrofit.** { *; }

to our proguard rules to keep the SDK from crashing. It might be helpful for others to know if they're using proguard.

Gradle build error

Hi, I'm adding library like this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
    compile "io.filepicker:filepicker-android:3.8.3"
}

and I got next gradle error

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:support-v4:21.0.2.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/21.0.2/support-v4-21.0.2.pom
https://jcenter.bintray.com/com/android/support/support-v4/21.0.2/support-v4-21.0.2.jar
file:/C:/Program Files (x86)/Android/android-studio/sdk/extras/android/m2repository/com/android/support/support-v4/21.0.2/support-v4-21.0.2.pom
file:/C:/Program Files (x86)/Android/android-studio/sdk/extras/android/m2repository/com/android/support/support-v4/21.0.2/support-v4-21.0.2.jar
file:/C:/Program Files (x86)/Android/android-studio/sdk/extras/google/m2repository/com/android/support/support-v4/21.0.2/support-v4-21.0.2.pom
file:/C:/Program Files (x86)/Android/android-studio/sdk/extras/google/m2repository/com/android/support/support-v4/21.0.2/support-v4-21.0.2.jar
Required by:
AClock:app:unspecified > io.filepicker:filepicker-android:3.8.3

Google Drive Support

Hello,
When using Google Drive to retrieve an image, there is no preview only a small black document icon. The localPath that is returned when selecting the image is null.

Row icons for large screens

Hello,
Is it possible to include different service icons by resource buckets ie, drawable-xxhdpi, drawable-xhdpi, etc... The icons start looking very pixelated when viewing FilePicker on larger devices.

Have you guys also considered using a GridView vs Listview on larger devices such as tablets?

filepicker

Local File Path not returned

The local file path is no longer returned in FPFile. This used to be returned in the previous version.
Having the local path is useful for verifying additional features of a file instead of having to download the file again through the provided url.

Filepicker Api setAppName

Currently Filepicker.setAppName() has no effect. Have you considered allowing a user to put a App name through the calling intent? Setting an app name through a static method runs the risk of the name being GC'd.

Memory Leak 3.7.3

FilePicker has a memory leak. It can be observed when rotating a device a couple of times. Using Strict Mode, you will receive a "InstanceCountViolation" and from the Memory Analyzer screenshot you can see that there is multiple FilePicker Activity entries.

screen shot 2015-01-09 at 11 49 04 am

UI Bug - Progressbar and Actionbar Up Caret

The Progressbar no longer shows up when choosing a image from the photo gallery and the up carot in the actionbar is also gone.

The progressbar most likely doesn't show up due to onActivityResult being called prematurely before onCreate. See: http://stackoverflow.com/questions/3354955/onactivityresult-called-prematurely

To fix this, the intent data needs to be saved and then checked in onCreate or onResume when the UI can be modified. This can also possibly be fixed using android:launchMode="singleTop"

The Actionbar icon being set to homeAsUpEnabled is a established convention that hints to the user that they can go back to a previous activity. Would be great to at least have the option of setting this.

This was tested on a HTC One(m7) with Android 5.0.1.
file-picker-3 7 1

JSONException in FilePickerApi#uploadFileToTemp()

After picking a file a JSONException is thrown from FilePickerApi#uploadFileToTemp when trying get a JSON object.

The code does this:

JSONObject data = json.getJSONObject("data").getJSONObject("data");

When it should do this:

JSONObject data = json.getJSONArray("data").getJSONObject(0);

Crash on isProbablyImage method in Filepicker

I'm seeing this crash in FilePicker 3.8.0 on various Samsung, LG, HTC devices. The stacktrace was collected through Crashlytics.

java.lang.StringIndexOutOfBoundsException: length=107; regionStart=104; regionLength=-9
at java.lang.String.startEndAndLength(String.java:588)
at java.lang.String.substring(String.java:1475)
at java.net.DefaultFileNameMap.getContentTypeFor(DefaultFileNameMap.java:38)
at java.net.URLConnection.guessContentTypeFromName(URLConnection.java:681)
at io.filepicker.models.Node.isProbablyImage(Node.java:60)
at io.filepicker.adapters.NodesAdapter.getItemViewType(NodesAdapter.java:133)
at android.widget.AbsListView$RecycleBin.getScrapView(AbsListView.java:7240)
at android.widget.AbsListView.obtainView(AbsListView.java:2423)
at android.widget.GridView.onMeasure(GridView.java:1044)
at android.view.View.measure(View.java:16736)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16736)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16736)

Http 400 error on all cloud services

D/FilePickerAPI﹕ Http error: 400
12-19 10:10:36.769  19598-19640/com.firezenk.*** W/System.err﹕ java.io.IOException
12-19 10:10:36.779  19598-19640/com.firezenk.*** W/System.err﹕ at io.filepicker.FilePickerAPI.getStringFromNetworkRequest(FilePickerAPI.java:600)
12-19 10:10:36.779  19598-19640/com.firezenk.*** W/System.err﹕ at io.filepicker.FilePickerAPI.getPath(FilePickerAPI.java:349)
12-19 10:10:36.779  19598-19640/com.firezenk.*** W/System.err﹕ at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:159)

Please give me a solution asap.

Google authentication keeps requesting access

A user recently reported a problem with the filepicker.io plugin in my app "OpenDocument Reader". You can find the report here: http://opendocument.uservoice.com/forums/185155-general/suggestions/3745087-fix-filepicker-io-authentication

I've verified this on a Samsung Galaxy S3 running CyanogenMod 10.something, Android 4.2.2.

You can find the source of my app here: https://github.com/TomTasche/OpenDocument.droid

Here's what logcat looks like:
03-18 18:57:01.675: I/ActivityManager(2259): Displayed at.tomtasche.reader/io.filepicker.FilePicker: +318ms
03-18 18:57:01.945: D/dalvikvm(23954): GC_CONCURRENT freed 638K, 14% free 5699K/6580K, paused 3ms+4ms, total 33ms
03-18 18:57:02.215: D/FilePickerAPI(23954): Builder string: {"client": "gmail", "loginFields": null, "contents": [], "auth": false, "filename": "Gmail"}
03-18 18:57:02.225: D/FilePickerAPI(23954): Auth error: not caching
03-18 18:57:02.225: D/FilePickerAPI(23954): Builder string: {"client": "box", "loginFields": null, "contents": [], "auth": false, "filename": "Box"}
03-18 18:57:02.230: D/FilePickerAPI(23954): Auth error: not caching
03-18 18:57:02.230: D/FilePickerAPI(23954): Builder string: {"client": "dropbox", "loginFields": null, "contents": [], "auth": false, "filename": "Dropbox"}
03-18 18:57:02.235: D/FilePickerAPI(23954): Auth error: not caching
03-18 18:57:02.460: D/FilePickerAPI(23954): Builder string: {"client": "gdrive", "loginFields": null, "contents": [], "auth": false, "filename": "Google Drive"}
03-18 18:57:02.465: D/FilePickerAPI(23954): Auth error: not caching
03-18 18:57:02.555: I/ActivityManager(2259): START u0 {typ=/ cmp=at.tomtasche.reader/io.filepicker.FilePicker (has extras)} from pid 23954
03-18 18:57:02.650: D/FilePickerAPI(23954): getPath path: /GDrive/
03-18 18:57:02.820: W/Resources(2259): Converting to int: TypedValue{t=0x3/d=0x182 "400" a=2 r=0x7f0b0013}
03-18 18:57:02.820: I/ActivityManager(2259): Displayed at.tomtasche.reader/io.filepicker.FilePicker: +193ms
03-18 18:57:03.145: D/FilePickerAPI(23954): Builder string: {"client": "gdrive", "loginFields": null, "contents": [], "auth": false, "filename": "Google Drive"}
03-18 18:57:03.145: W/System.err(23954): io.filepicker.AuthError
03-18 18:57:03.150: W/System.err(23954): at io.filepicker.FilePickerAPI.parseFolder(FilePickerAPI.java:228)
03-18 18:57:03.150: W/System.err(23954): at io.filepicker.FilePickerAPI.getPath(FilePickerAPI.java:345)
03-18 18:57:03.160: W/System.err(23954): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:156)
03-18 18:57:03.160: W/System.err(23954): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:1)
03-18 18:57:03.160: W/System.err(23954): at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-18 18:57:03.160: W/System.err(23954): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
03-18 18:57:03.160: W/System.err(23954): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-18 18:57:03.160: W/System.err(23954): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
03-18 18:57:03.160: W/System.err(23954): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
03-18 18:57:03.160: W/System.err(23954): at java.lang.Thread.run(Thread.java:856)
03-18 18:57:03.165: I/ActivityManager(2259): START u0 {cmp=at.tomtasche.reader/io.filepicker.AuthActivity (has extras)} from pid 23954
03-18 18:57:03.375: D/dalvikvm(23954): GC_CONCURRENT freed 880K, 16% free 5841K/6904K, paused 4ms+8ms, total 63ms
03-18 18:57:03.490: I/ActivityManager(2259): Displayed at.tomtasche.reader/io.filepicker.AuthActivity: +215ms
03-18 18:57:03.685: I/ActivityManager(2259): Process com.google.android.googlequicksearchbox (pid 23788) has died.
03-18 18:57:03.700: I/ActivityManager(2259): Process com.google.android.gm (pid 23646) has died.
03-18 18:57:03.700: I/ActivityManager(2259): Process com.google.android.apps.maps:LocationFriendService (pid 23796) has died.
03-18 18:57:04.265: V/chromium(23954): external/chromium/net/base/bandwidth_metrics.h:96: [0318/185704:INFO:bandwidth_metrics.h(96)] Bandwidth: 4144.45Kbps (avg 4144.45Kbps)
03-18 18:57:04.630: W/chromium(23954): external/chromium/net/spdy/spdy_session.cc:1058: [0318/185704:WARNING:spdy_session.cc(1058)] Received data frame for invalid stream 1
03-18 18:57:04.645: W/chromium(23954): external/chromium/net/spdy/spdy_session.cc:1058: [0318/185704:WARNING:spdy_session.cc(1058)] Received data frame for invalid stream 3
03-18 18:57:08.040: D/dalvikvm(23954): GC_FOR_ALLOC freed 500K, 16% free 6020K/7160K, paused 19ms, total 19ms
03-18 18:57:08.065: D/dalvikvm(23954): GC_FOR_ALLOC freed 8K, 16% free 6258K/7416K, paused 14ms, total 14ms
03-18 18:57:09.795: W/Resources(2259): Converting to int: TypedValue{t=0x3/d=0x182 "400" a=2 r=0x7f0b0013}
03-18 18:57:09.825: D/FilePickerAPI(23954): getPath path: /GDrive/
03-18 18:57:10.275: D/FilePickerAPI(23954): Builder string: {"client": "gdrive", "loginFields": null, "contents": [], "auth": false, "filename": "Google Drive"}
03-18 18:57:10.275: W/System.err(23954): io.filepicker.AuthError
03-18 18:57:10.275: W/System.err(23954): at io.filepicker.FilePickerAPI.parseFolder(FilePickerAPI.java:228)
03-18 18:57:10.275: W/System.err(23954): at io.filepicker.FilePickerAPI.getPath(FilePickerAPI.java:345)
03-18 18:57:10.280: W/System.err(23954): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:156)
03-18 18:57:10.280: W/System.err(23954): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:1)
03-18 18:57:10.280: W/System.err(23954): at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-18 18:57:10.280: W/System.err(23954): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
03-18 18:57:10.280: W/System.err(23954): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-18 18:57:10.280: W/System.err(23954): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
03-18 18:57:10.280: W/System.err(23954): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
03-18 18:57:10.280: W/System.err(23954): at java.lang.Thread.run(Thread.java:856)
03-18 18:57:10.285: I/ActivityManager(2259): START u0 {cmp=at.tomtasche.reader/io.filepicker.AuthActivity (has extras)} from pid 23954
03-18 18:57:10.475: I/ActivityManager(2259): Displayed at.tomtasche.reader/io.filepicker.AuthActivity: +140ms

Authenticating then choosing 'Allow' just cycles back and forth between activity views

Simple Android project with the filepicker android library included.
Using latest code from this repo. Up to this latest (3a65a24) commit.

Please watch what happens:

http://www.youtube.com/watch?v=dwTPLN6TW1g

This is the Android MainActivity.java code I'm using to launch the intent in this simple project (test harness setup):

package com.example.testappfilepicker;

import io.filepicker.FPService;
import io.filepicker.FilePicker;
import io.filepicker.FilePickerAPI;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        FilePickerAPI.setKey( "my api key - **omitted here to keep private**" );

        Intent intent = new Intent(this, FilePicker.class);

        startActivityForResult(intent, FilePickerAPI.REQUEST_CODE_GETFILE);


    }

    @Override
    protected void onActivityResult(int requestCode,
                                    int resultCode, Intent data) {
        if (requestCode == FilePickerAPI.REQUEST_CODE_GETFILE) {
            if (resultCode != RESULT_OK)
            //Result was cancelled by the user or there was an error
                    return;
            Uri uri = data.getData();
            System.out.println("File path is " + uri.toString());
            System.out.println("Ink file URL: " + data.getExtras().getString("fpurl"));
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

Can anyone help me? Is anyone else having this problem?

Gradle Properties Bug

Hello, the project can no longer be built using Gradle due to VERSION_NAME and VERSION_CODE not being defined. Are these values possibly defined in a gradle.properties that is not being included in the project?

Configuration Changes

When logging into a service the first time say for example Flickr, when on the login page if the user rotates the device the login page disappears and you get a menu option that says "Logout" but the user has not logged in. This also happens with other configuration changes such as when switching languages.

Also if a user has already logged into another service before Flickr, if the device is rotated while on the login, the title reads Flickr but the other services' files get displayed.

flickr-login

flickr-login-rotate

fpurl empty for Android 2.3

Hello,

We are facing troubles uploading images in Android 2.3. When we get the response from filepicker and we try to get the "fpurl" this value is empty. This is working in Android 4.

We found this bug at least in a:

  • Samsung s2 with Android 2.3
  • Sony Ericsson Xperia arc S with Android 2.3

gradle/maven..

Thanks for this lib.

Can you guys put this on maven or such...
so it's accessible via gradle/android studio, real easily.

Thank You for your work.

Authorization for cloud services not working

Hi,
Today I started implementing filepicker.io in my android native application, but i've ran into a strange bug (that i confirmed that exists also in the sample projects, like notepad master).

The activity works fine (as in it shows the import type chooser) however whenever i try to authenticate to a cloud service (google drive, dropbox, etc) i get this:

05-15 14:48:05.330: W/System.err(781): io.filepicker.AuthError
05-15 14:48:05.330: W/System.err(781): at io.filepicker.FilePickerAPI.parseFolder(FilePickerAPI.java:228)
05-15 14:48:05.350: W/System.err(781): at io.filepicker.FilePickerAPI.getPath(FilePickerAPI.java:345)
05-15 14:48:05.350: W/System.err(781): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:156)
05-15 14:48:05.350: W/System.err(781): at io.filepicker.FilePicker$FpapiTask.doInBackground(FilePicker.java:1)
05-15 14:48:05.360: W/System.err(781): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-15 14:48:05.360: W/System.err(781): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-15 14:48:05.370: W/System.err(781): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-15 14:48:05.380: W/System.err(781): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-15 14:48:05.380: W/System.err(781): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-15 14:48:05.390: W/System.err(781): at java.lang.Thread.run(Thread.java:856)
05-15 14:48:05.790: W/EGL_emulation(781): eglSurfaceAttrib not implemented

I would put my code here, but since it also happens with the notepad sample project i think its a server-side problem.

Gallery file retrieval works fine. It just happens with cloud services, during authentication.

Any help would be good.

Filepicker crashes when Gallery->Drive photo selected

Filepicker always crashes when selecting a photo from Gallery -> Drive . This is happening on a HTC One m7 with Android 5.0.1.

Below is the logcat:
java.lang.NullPointerException
at io.filepicker.services.ContentService.handleActionUploadFile(ContentService.java:158)
at io.filepicker.services.ContentService.onHandleIntent(ContentService.java:101)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

gallery-drive

Unable to load local path returned by Samsung Galaxy S4

We're having an issue where we are unable to load a local image path returned from a galaxy s4 phone when a photo is taken from the camera. The image url is returned but the local path appears to be invalid.

Have you guys seen any particular bugs with respect to samsung devices? Maybe its related to this? square/picasso#539

Insane logging despite debug = false

My logcat is full of filepicker messages, although I didn't activate debugging (and it seems to be intended to be disabled by default). An example: https://github.com/Filepicker/filepicker-android/blob/master/src/io/filepicker/FilePickerAPI.java#L333

The messages I see in logcat are along the lines of the following:
11-26 18:55:44.340: D/FilePickerAPI(7059): inodeForJSONObject: {"thumb_exists":true,"display_name":"IMG_20101126_134621.jpg","mimetype":"image\/jpg","thumbnail":"https:\/\/www.filepicker.io\/api\/path\/Dropbox\/Public\/IMG_20101126_134621.jpg?format=thumbnail","bytes":858202,"filename":"IMG_20101126_134621.jpg","is_dir":false,"size":"838.1 KB","modified":"1 year ago","link_path":"\/Dropbox\/Public\/IMG_20101126_134621.jpg"}

uploadLocalFile callback

The Filepicker.uploadLocalFile(uriToLocalFile, context); call should have a return value or callback like in the JavaScript library. There is currently no way to actually get the stored blob meta on Android (or I must be missing something).

Theme naming

Theme overrides any theme that's also named AppTheme without the explicit overriding of the resource. Simply rename AppTheme to something like FilepickerTheme as that will also make the Theme overridable.

OkHttp and Retrofit Exceptions

Hello, I'm seeing some exceptions related to both libraries. I dont think these crashes actually happen on the latest versions of these libraries. I think they end up being treated as "RerofitError" instead of making apps crash. Have you considered upgrading?

  compile 'com.squareup.retrofit:retrofit:1.9.0'
  compile 'com.squareup.okhttp:okhttp:2.2.0'
  compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'

Its probably also worth upgrading Picasso to 2.5.0, with retrofit 1.9.0 and picasso 2.5.0 you no longer need the okhttp-urlconnection shim dependency.

Here are the crashes I'm seeing:

retrofit.RetrofitError: Unable to resolve host "dialog.filepicker.io": No address associated with hostname
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at $Proxy11.pickFile()

retrofit.RetrofitError: timeout
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at $Proxy19.pickFile()
at io.filepicker.services.ContentService.handleActionPickFiles(ContentService.java:151)
at io.filepicker.services.ContentService.onHandleIntent(ContentService.java:112)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.io.InterruptedIOException: timeout

Crash getTypedFileFromUri

Have seen this crash a couple times on multiple versions of FilePicker. Currently I am using 3.8.0

This crash is from an HTC One(m7).

java.lang.NullPointerException: mimeType
at retrofit.mime.TypedFile.(TypedFile.java:42)
at io.filepicker.utils.FilesUtils.getTypedFileFromUri(FilesUtils.java:39)
at io.filepicker.services.ContentService.handleActionUploadFile(ContentService.java:163)
at io.filepicker.services.ContentService.onHandleIntent(ContentService.java:108)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.os.HandlerThread.run(HandlerThread.java:61)

NPE when selecting file

Hey guys,

I've tried to pick a file from Dropbox and Google Drive, but both didn't work (ended up with a force close). Here's the stacktrace:

11-25 17:41:28.515: W/System.err(18274): org.json.JSONException: No value for key 11-25 17:41:28.520: W/System.err(18274): at org.json.JSONObject.get(JSONObject.java:354) 11-25 17:41:28.520: W/System.err(18274): at org.json.JSONObject.getString(JSONObject.java:510) 11-25 17:41:28.520: W/System.err(18274): at io.filepicker.FilePickerAPI.getLocalFileForPath(FilePickerAPI.java:493) 11-25 17:41:28.520: W/System.err(18274): at io.filepicker.FilePicker$PickFileTask.doInBackground(FilePicker.java:280) 11-25 17:41:28.520: W/System.err(18274): at io.filepicker.FilePicker$PickFileTask.doInBackground(FilePicker.java:1) 11-25 17:41:28.520: W/System.err(18274): at android.os.AsyncTask$2.call(AsyncTask.java:287) 11-25 17:41:28.520: W/System.err(18274): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 11-25 17:41:28.520: W/System.err(18274): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-25 17:41:28.520: W/System.err(18274): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 11-25 17:41:28.520: W/System.err(18274): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 11-25 17:41:28.520: W/System.err(18274): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 11-25 17:41:28.525: W/System.err(18274): at java.lang.Thread.run(Thread.java:856) 11-25 17:41:28.525: W/dalvikvm(18274): threadid=1: thread exiting with uncaught exception (group=0x42036300) 11-25 17:41:28.530: E/AndroidRuntime(18274): FATAL EXCEPTION: main 11-25 17:41:28.530: E/AndroidRuntime(18274): java.lang.NullPointerException 11-25 17:41:28.530: E/AndroidRuntime(18274): at io.filepicker.FilePicker$PickFileTask.onPostExecute(FilePicker.java:291) 11-25 17:41:28.530: E/AndroidRuntime(18274): at io.filepicker.FilePicker$PickFileTask.onPostExecute(FilePicker.java:1) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.os.AsyncTask.finish(AsyncTask.java:631) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.os.AsyncTask.access$600(AsyncTask.java:177) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.os.Handler.dispatchMessage(Handler.java:99) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.os.Looper.loop(Looper.java:137) 11-25 17:41:28.530: E/AndroidRuntime(18274): at android.app.ActivityThread.main(ActivityThread.java:4931) 11-25 17:41:28.530: E/AndroidRuntime(18274): at java.lang.reflect.Method.invokeNative(Native Method) 11-25 17:41:28.530: E/AndroidRuntime(18274): at java.lang.reflect.Method.invoke(Method.java:511) 11-25 17:41:28.530: E/AndroidRuntime(18274): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 11-25 17:41:28.530: E/AndroidRuntime(18274): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558) 11-25 17:41:28.530: E/AndroidRuntime(18274): at dalvik.system.NativeStart.main(Native Method)

Unnecessary service selection

If you request a File Pick specifying only one service, you still have to pick that service from a list of one before you see your files. It would be a better user experience to go straight to the auth or files view in this case.

thanks

Unable to run the Sample application

Hello,

I am using this filepicker-android.

I am get this error at line startActivityForResult(intent, Filepicker.REQUEST_CODE_GETFILE);
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.filemanager/io.filepicker.Filepicker}; have you declared this activity in your AndroidManifest.xml?

i followed all the steps given in this link https://github.com/Ink/filepicker-android

Is their any thing else which i am missing

No Progress Bar on file upload

There is no longer a progressbar when a file is being uploaded. A toast briefly shows up when first uploading but no indicator after that. The UX can be improved with a progress bar, otherwise a user will not know to wait and might press back or home before a file is uploaded. This would affect the UX of the app using filepicker-android.

Unable to find URL of uploaded file

File is uploaded successfully but i am not able to get the URL of file uploaded on Filepicker.
i dont want any operation on that just the URL.
Sample code creates FpFile object and stores Parcelable response to it but creating that object returns me nullpointer.

Error when trying upload something on Android 4.3

The error line:

this.key = fileData.getString("key");

The patch solution:

this.key = "MY_API_KEY";

Because the "key" string is not in the JSONObject...

Log:
11-14 12:49:23.244: E/AndroidRuntime(22088): FATAL EXCEPTION: AsyncTask #4
11-14 12:49:23.244: E/AndroidRuntime(22088): java.lang.RuntimeException: An error occured while executing doInBackground()
11-14 12:49:23.244: E/AndroidRuntime(22088):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.lang.Thread.run(Thread.java:841)
11-14 12:49:23.244: E/AndroidRuntime(22088): Caused by: java.lang.RuntimeException: org.json.JSONException: No value for key
11-14 12:49:23.244: E/AndroidRuntime(22088):    at io.filepicker.FPFile.<init>(FPFile.java:92)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at io.filepicker.FilePickerAPI.uploadFileToTemp(FilePickerAPI.java:468)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at io.filepicker.FilePicker$UploadLocalFileTask.doInBackground(FilePicker.java:313)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at io.filepicker.FilePicker$UploadLocalFileTask.doInBackground(FilePicker.java:1)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-14 12:49:23.244: E/AndroidRuntime(22088):    ... 4 more
11-14 12:49:23.244: E/AndroidRuntime(22088): Caused by: org.json.JSONException: No value for key
11-14 12:49:23.244: E/AndroidRuntime(22088):    at org.json.JSONObject.get(JSONObject.java:354)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at org.json.JSONObject.getString(JSONObject.java:514)
11-14 12:49:23.244: E/AndroidRuntime(22088):    at io.filepicker.FPFile.<init>(FPFile.java:89)
11-14 12:49:23.244: E/AndroidRuntime(22088):    ... 9 more

EventBus Crash

I'm starting to get reports of a crash associated with an EventBus:

java.lang.NullPointerException
at de.greenrobot.event.EventBus.postSingleEvent(EventBus.java:376)
at de.greenrobot.event.EventBus.post(EventBus.java:263)
at io.filepicker.services.ContentService.handleError(ContentService.java:220)
at io.filepicker.services.ContentService.access$000(ContentService.java:34)
at io.filepicker.services.ContentService$1.failure(ContentService.java:129)
at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(NativeStart.java)

I am currently using Filepicker 3.8.11

Better app integration

Using your api, I've noticed that in your main activity "FilePicker.class", you may consider adding the following:

public void onCreate(Bundle savedInstanceState) {
      [...]
      getActionBar().setDisplayHomeAsUpEnabled(true);
      [...]
}

This is to add the visual way back to the parent activity in the ActionBar, this provides more usability to this activity.

Adding this line, you must add the following function to get it work:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
        }
        return super.onOptionsItemSelected(item);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.