4
4
import android .app .AlertDialog ;
5
5
import android .content .ContentResolver ;
6
6
import android .content .Context ;
7
- import android .content .DialogInterface ;
8
- import android .content .DialogInterface .OnCancelListener ;
9
7
import android .content .Intent ;
10
8
import android .content .SharedPreferences ;
11
9
import android .content .res .Resources ;
@@ -179,12 +177,7 @@ private void showCannotOpenDialog(String reason) {
179
177
Resources res = getResources ();
180
178
AlertDialog alert = mAlertBuilder .create ();
181
179
setTitle (String .format (Locale .ROOT , res .getString (R .string .cannot_open_document_Reason ), reason ));
182
- alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ),
183
- new DialogInterface .OnClickListener () {
184
- public void onClick (DialogInterface dialog , int which ) {
185
- finish ();
186
- }
187
- });
180
+ alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ), (dialog , which ) -> finish ());
188
181
alert .show ();
189
182
}
190
183
@@ -214,10 +207,13 @@ public void onCreate(final Bundle savedInstanceState)
214
207
215
208
mReturnToLibraryActivity = intent .getIntExtra (getComponentName ().getPackageName () + ".ReturnToLibraryActivity" , 0 ) != 0 ;
216
209
217
- if (Intent .ACTION_VIEW .equals (intent .getAction ())) {
210
+ if (Intent .ACTION_VIEW .equals (intent .getAction ())
211
+ || Intent .ACTION_SEND .equals (intent .getAction ())) {
218
212
Uri uri = intent .getData ();
219
213
String mimetype = getIntent ().getType ();
220
-
214
+ if (uri == null ) {
215
+ uri = intent .getParcelableExtra (Intent .EXTRA_STREAM );
216
+ }
221
217
if (uri == null ) {
222
218
showCannotOpenDialog ("No document uri to open" );
223
219
return ;
@@ -289,18 +285,8 @@ public void onCreate(final Bundle savedInstanceState)
289
285
{
290
286
AlertDialog alert = mAlertBuilder .create ();
291
287
alert .setTitle (R .string .cannot_open_document );
292
- alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ),
293
- new DialogInterface .OnClickListener () {
294
- public void onClick (DialogInterface dialog , int which ) {
295
- finish ();
296
- }
297
- });
298
- alert .setOnCancelListener (new OnCancelListener () {
299
- @ Override
300
- public void onCancel (DialogInterface dialog ) {
301
- finish ();
302
- }
303
- });
288
+ alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ), (dialog , which ) -> finish ());
289
+ alert .setOnCancelListener (dialog -> finish ());
304
290
alert .show ();
305
291
return ;
306
292
}
@@ -317,22 +303,14 @@ public void requestPassword(final Bundle savedInstanceState) {
317
303
alert .setTitle (R .string .enter_password );
318
304
alert .setView (mPasswordView );
319
305
alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .okay ),
320
- new DialogInterface .OnClickListener () {
321
- public void onClick (DialogInterface dialog , int which ) {
322
- if (core .authenticatePassword (mPasswordView .getText ().toString ())) {
323
- createUI (savedInstanceState );
324
- } else {
325
- requestPassword (savedInstanceState );
326
- }
306
+ (dialog , which ) -> {
307
+ if (core .authenticatePassword (mPasswordView .getText ().toString ())) {
308
+ createUI (savedInstanceState );
309
+ } else {
310
+ requestPassword (savedInstanceState );
327
311
}
328
312
});
329
- alert .setButton (AlertDialog .BUTTON_NEGATIVE , getString (R .string .cancel ),
330
- new DialogInterface .OnClickListener () {
331
-
332
- public void onClick (DialogInterface dialog , int which ) {
333
- finish ();
334
- }
335
- });
313
+ alert .setButton (AlertDialog .BUTTON_NEGATIVE , getString (R .string .cancel ), (dialog , which ) -> finish ());
336
314
alert .show ();
337
315
}
338
316
0 commit comments