Turbolinks 5 and Android: Fails when use file upload (webview)

325 views Asked by At

Problem

When the user clicks on choose file, I intercept that click natively and I call the native view (screen 3 in the mockup).

After the user select the file he wants to upload, I need to "reload" the view in order to add the name of the file in the form, so the user can get the feedback that he selected the file correctly.

In order to do this, I'm calling onRestart with the following code:

 @Override
 protected void onRestart() {
     super.onRestart();

     // mCM is a variable to detect when the user is choosing a file.
     if (null == mCM) {
         // Since the webView is shared between activities, we need to tell Turbolinks
         // to load the location from the previous activity upon restarting
         TurbolinksSession.getDefault(this)
                 .activity(this)
                 .adapter(this)
                 .restoreWithCachedSnapshot(true)
                 .view(turbolinksView)
                 .visit(location);
      }
 }

As you can see, in this method when is uploading a file I do NOT reload the view using TurbolinksSession.

But if I don't call TurbolinksSession, Turbolinks never calls visitProposedToLocationWithAction.

Scenario

new mockup 1

NOTE: Download the image if you want to see the image bigger.

What am I missing? Is there a way to solve this problem and get the expected result?

1

There are 1 answers

1
Mohamed Ziata On