@ -26,42 +26,41 @@ public class LightningDownloadListener implements DownloadListener {
@@ -26,42 +26,41 @@ public class LightningDownloadListener implements DownloadListener {
@Override
public void onDownloadStart ( final String url , final String userAgent ,
final String contentDisposition , final String mimetype , long contentLength ) {
PermissionsManager . getInstance ( ) . requestPermissionsIfNecessaryForResult ( mActivity , new String [ ] { Manifest . permission . READ_EXTERNAL_STORAGE ,
Manifest . permission . WRITE_EXTERNAL_STORAGE } , new PermissionsManager . PermissionResult ( ) {
@Override
public void onGranted ( ) {
String fileName = URLUtil . guessFileName ( url , contentDisposition , mimetype ) ;
DialogInterface . OnClickListener dialogClickListener = new DialogInterface . OnClickListener ( ) {
PermissionsManager . getInstance ( ) . requestPermissionsIfNecessaryForResult ( mActivity ,
new String [ ] { Manifest . permission . READ_EXTERNAL_STORAGE , Manifest . permission . WRITE_EXTERNAL_STORAGE } ,
new PermissionsManager . PermissionResult ( ) {
@Override
public void onClick ( DialogInterface dialog , int which ) {
switch ( which ) {
case DialogInterface . BUTTON_POSITIVE :
DownloadHandler . onDownloadStart ( mActivity , url , userAgent ,
contentDisposition , mimetype ) ;
break ;
public void onGranted ( ) {
String fileName = URLUtil . guessFileName ( url , contentDisposition , mimetype ) ;
DialogInterface . OnClickListener dialogClickListener = new DialogInterface . OnClickListener ( ) {
@Override
public void onClick ( DialogInterface dialog , int which ) {
switch ( which ) {
case DialogInterface . BUTTON_POSITIVE :
DownloadHandler . onDownloadStart ( mActivity , url , userAgent ,
contentDisposition , mimetype ) ;
break ;
case DialogInterface . BUTTON_NEGATIVE :
break ;
}
}
} ;
AlertDialog . Builder builder = new AlertDialog . Builder ( mActivity ) ; // dialog
builder . setTitle ( fileName )
. setMessage ( mActivity . getResources ( ) . getString ( R . string . dialog_download ) )
. setPositiveButton ( mActivity . getResources ( ) . getString ( R . string . action_download ) ,
dialogClickListener )
. setNegativeButton ( mActivity . getResources ( ) . getString ( R . string . action_cancel ) ,
dialogClickListener ) . show ( ) ;
Log . i ( Constants . TAG , "Downloading" + fileName ) ;
}
@Override
public void onDenied ( String permission ) {
//TODO show message
}
} ) ;
case DialogInterface . BUTTON_NEGATIVE :
break ;
}
}
} ;
AlertDialog . Builder builder = new AlertDialog . Builder ( mActivity ) ; // dialog
builder . setTitle ( fileName )
. setMessage ( mActivity . getResources ( ) . getString ( R . string . dialog_download ) )
. setPositiveButton ( mActivity . getResources ( ) . getString ( R . string . action_download ) ,
dialogClickListener )
. setNegativeButton ( mActivity . getResources ( ) . getString ( R . string . action_cancel ) ,
dialogClickListener ) . show ( ) ;
Log . i ( Constants . TAG , "Downloading" + fileName ) ;
}
@Override
public void onDenied ( String permission ) {
//TODO show message
}
} ) ;
}
}