Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Development and suggestions about third part tool integration.
Cordova, Xamarin, Basic4Android topics are listed here.
  • Page:
  • 1

TOPIC:

Question about cordova plugin 8 years 3 months ago #11384

  • eastxing
  • eastxing's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
How to know the user has back from radaee pdf reader view and the file has been modified?

Hello,

I add cordova plugin into a cordova app, I want to use it like this:

1. show a pdf files list to user;
2. user click one file then download it from server;
3. after file download, open it by radaee pdf reader;
4. user add some annotation and click back button, a dialog popup prompt user to save the modification;
5. user click "ok" button, save the pdf;
6. back to the first pdf files list view;
7. upload the modified pdf file to server;

I have implemented all steps except step 7, because I don't know when the user back from radaee pdf reader view and the file has been modified or not.

Thank you.

Please Log in or Create an account to join the conversation.

Question about cordova plugin 8 years 3 months ago #11385

  • support
  • support's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 695
  • Thank you received: 59
Are you using the radaee pdf reader plugin within your Cordova application?
Is that's the case, we might introduce a new js command to retrive such an information.

I should ask you to be patient while waiting for our update.

Please Log in or Create an account to join the conversation.

Question about cordova plugin 8 years 3 months ago #11387

  • eastxing
  • eastxing's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
Yes, I using radaee pdf reader plugin in my cordova app.
Looking forward to your update.

Thank you.

Please Log in or Create an account to join the conversation.

Question about cordova plugin 8 years 2 months ago #11410

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
We have updated our Cordova plugin ..
We have added a new js interface (getFileState) that can be used to get the state of the last opened file (not modified, modified but not saved, modified and saved)...
RadaeePDFPlugin.getFileState(
                               { },
                               function(message) {
                                    console.log("Success: " + message);
                               },
                               function(err){
                                   console.log("Failure: " + err);
                        });
The plugin is now aligned with the latest Android version.

Please Log in or Create an account to join the conversation.

Question about cordova plugin 8 years 2 months ago #11430

  • eastxing
  • eastxing's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
Thanks for your update.
But it is not my need. I still do not know when the user back from the PDF view to my app view (by pressed back button).
At last I implemented it myself by modify the cordova plugin source code.

To put it simply,
1. Modify file RadaeePDFPlugin.java;

comment:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

change:
mContext.startActivity(intent);

to:
this.cordova.startActivityForResult((CordovaPlugin)this, intent, 0);

and add:
@Override
    public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        if(requestCode == 0) {
            if(resultCode == cordova.getActivity().RESULT_OK) {
                Bundle extras = data.getExtras();// Get data sent by the Intent
                String information = extras.getString("fileState"); // data parameter will be send from the other activity.

                PluginResult resultado = new PluginResult(PluginResult.Status.OK, information);
                resultado.setKeepCallback(true);
                PUBLIC_CALLBACKS.sendPluginResult(resultado);
                return;
            }
            else if(resultCode == cordova.getActivity().RESULT_CANCELED) {
                PluginResult resultado = new PluginResult(PluginResult.Status.OK, "canceled action, process this in javascript");
                resultado.setKeepCallback(true);
                PUBLIC_CALLBACKS.sendPluginResult(resultado);
                return;
            }
        }

        // Handle other results if exists.
        super.onActivityResult(requestCode, resultCode, data);
    }

2. Modify file PDFViewAct.java;

change function 'onBackPressed' to:
@Override
public void onBackPressed()
{
    if(m_controller == null || m_controller.OnBackPressed())
    {
        if(m_modified) {
            TextView txtView = new TextView(this);
            txtView.setText("Document modified\r\nDo you want save it?");
            new AlertDialog.Builder(this).setTitle("Exiting").setView(
                    txtView).setPositiveButton("Yes", new DialogInterface.OnClickListener()
                    {
                       @Override
                       public void onClick(DialogInterface dialog, int which)
                       {
                            m_doc.Save();
                           
                            Intent mIntent = new Intent();
                            mIntent.putExtra("fileState", "modifiedAndSaved");
                            PDFViewAct.this.setResult(RESULT_OK, mIntent);

                            PDFViewAct.super.onBackPressed();
                       }
                   }).setNegativeButton("No", new DialogInterface.OnClickListener()
                   {
                       @Override
                       public void onClick(DialogInterface dialog, int which)
                       {
                            Intent mIntent = new Intent();
                            mIntent.putExtra("fileState", "modifiedAndNotSaved");
                            PDFViewAct.this.setResult(RESULT_OK, mIntent);

                            PDFViewAct.super.onBackPressed();
                       }
                   }).show(); 
        }
        else {
            Intent mIntent = new Intent();
            mIntent.putExtra("fileState", "notModified");
            setResult(RESULT_OK, mIntent);

            super.onBackPressed();
        }
    }
}

Now when user back from PDF view, I can get file state and do my process.

Please Log in or Create an account to join the conversation.

Question about cordova plugin 8 years 2 months ago #11433

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
Thanks for the feedback,

But unfortunately, we cannot add such implementation in the standard version distribution; as it's oriented to apps specific needs and implementations.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum