MikeDimmickMnetics commented on issue #1388:
URL: 
https://github.com/apache/cordova-android/issues/1388#issuecomment-1980591611

   As an alternative, we could make `CordovaPlugin.onRequestPermissionsResult` 
(the new method's default implementation) call 
`CordovaPlugin.onRequestPermissionResult` (the old method, which may be 
overridden in plugins). Then change `CordovaInterfaceImpl` to only call 
`callback.first.onRequestPermissionsResult` (i.e. the new method).
   
   ```
   // CordovaPlugin.java
   
       /**
        * Called by the system when the user grants permissions
        *
        * @param requestCode
        * @param permissions
        * @param grantResults
        * 
        * @deprecated Use {@link #onRequestPermissionsResult} instead.
        */
       @Deprecated
       public void onRequestPermissionResult(int requestCode, String[] 
permissions,
                                             int[] grantResults) throws 
JSONException {
   
       }
   
       /**
        * Called by the system when the user grants permissions
        *
        * @param requestCode
        * @param permissions
        * @param grantResults
        */
       public void onRequestPermissionsResult(int requestCode, String[] 
permissions,
                                             int[] grantResults) throws 
JSONException {
           // Call the old method name for backward compatibility
           this.onRequestPermissionResult(requestCode, permissions, 
grantResults);
       }
   
   /// CordovaInterfaceImpl.java
   
       /**
        * Called by the system when the user grants permissions
        *
        * @param requestCode
        * @param permissions
        * @param grantResults
        */
       public void onRequestPermissionResult(int requestCode, String[] 
permissions,
                                             int[] grantResults) throws 
JSONException {
           Pair<CordovaPlugin, Integer> callback = 
permissionResultCallbacks.getAndRemoveCallback(requestCode);
           if(callback != null) {
               callback.first.onRequestPermissionsResult(callback.second, 
permissions, grantResults);
           }
       }
   ```
   
   It may be worth renaming the method in `CordovaInterface` (therefore also 
`CordovaInterfaceImpl`) for consistency.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to