Browse Source

Intent.ACTION_QUICK_VIEW experiment

main
M66B 6 years ago
parent
commit
1c27def6f1
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      app/src/main/java/eu/faircode/email/AdapterAttachment.java

+ 11
- 1
app/src/main/java/eu/faircode/email/AdapterAttachment.java View File

@ -21,9 +21,11 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.QuickViewConstants;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -147,9 +149,17 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
Log.i(Helper.TAG, "uri=" + uri); Log.i(Helper.TAG, "uri=" + uri);
// Build intent // Build intent
final Intent intent = new Intent(Intent.ACTION_VIEW);
final Intent intent = new Intent(
Build.VERSION.SDK_INT < Build.VERSION_CODES.N ? Intent.ACTION_VIEW : Intent.ACTION_QUICK_VIEW);
intent.setDataAndType(uri, attachment.type); intent.setDataAndType(uri, attachment.type);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
intent.putExtra(Intent.EXTRA_QUICK_VIEW_FEATURES, new String[]{
QuickViewConstants.FEATURE_VIEW,
QuickViewConstants.FEATURE_DOWNLOAD,
QuickViewConstants.FEATURE_SEND,
QuickViewConstants.FEATURE_PRINT
});
Log.i(Helper.TAG, "Sharing " + file + " type=" + attachment.type); Log.i(Helper.TAG, "Sharing " + file + " type=" + attachment.type);
Log.i(Helper.TAG, "Intent=" + intent); Log.i(Helper.TAG, "Intent=" + intent);


Loading…
Cancel
Save