Java源码示例:net.gsantner.opoc.util.ShareUtil

示例1
public void shareBitmapToOtherApp(Bitmap bitmap, Activity activity) {
        ShareUtil su = new ShareUtil(activity).setFileProviderAuthority(getString(R.string.app_fileprovider));
        su.setChooserTitle(getString(R.string.share_meme_via__appspecific));
        su.shareImage(bitmap, Bitmap.CompressFormat.JPEG, 65, "MT-meme");
/*
        File file = new File(getCacheDir(), getString(R.string.cached_picture_filename));
        if (ContextUtils.get().writeImageToFileJpeg(file, bitmap)) {
            Uri imageUri = FileProvider.getUriForFile(this, getString(R.string.app_fileprovider), file);
            if (imageUri != null) {
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                shareIntent.setDataAndType(imageUri, getContentResolver().getType(imageUri));
                shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
                activity.startActivity(Intent.createChooser(shareIntent, getString(R.string.main__share_meme_prompt)));
            }
        }*/
    }
 
示例2
private Bitmap extractBitmapFromIntent(final Intent intent) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    Bitmap bitmap = null;
    if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEND) && intent.getType().startsWith("image/")) {
        Uri imageURI = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        if (imageURI != null) {
            try {
                bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageURI);
            } catch (IOException e) {
                bitmap = null;
                e.printStackTrace();
            }
        }
    } else if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_EDIT) && intent.getType().startsWith("image/")) {
        ShareUtil shu = new ShareUtil(this);
        _predefinedTargetFile = shu.extractFileFromIntent(intent);
        if (_predefinedTargetFile == null) {
            Toast.makeText(this, R.string.the_file_could_not_be_loaded, Toast.LENGTH_SHORT).show();
            finish();
        }
        bitmap = ContextUtils.get().loadImageFromFilesystem(_predefinedTargetFile, _app.settings.getRenderQualityReal());
    } else {
        String imagePath = getIntent().getStringExtra(EXTRA_IMAGE_PATH);
        bitmap = ContextUtils.get().loadImageFromFilesystem(new File(imagePath), _app.settings.getRenderQualityReal());
    }
    return bitmap;
}
 
示例3
private void exportToCopy() {
    String filename = mSelectedLocaleResources.getFilename();
    String xml = mRepo.mergeDefaultTemplate(mSelectedLocale);

    new ShareUtil(this).setClipboard(xml);
    Toast.makeText(this, getString(R.string.xml_copied_to_clipboard, filename),
            Toast.LENGTH_SHORT).show();
}
 
示例4
private void exportToHastebin() {
    String xml = mRepo.mergeDefaultTemplate(mSelectedLocale);

    final ShareUtil shu = new ShareUtil(this);
    shu.pasteOnHastebin(xml, (ok, url) -> {
        if (ok) {
            shu.setClipboard(url);
        }
        Toast.makeText(TranslateActivity.this,
                ok ? R.string.exported_to_hastebin : R.string.export_unsuccessful,
                Toast.LENGTH_SHORT).show();
    });
}
 
示例5
private void exportToEmail() {
    String xml = mRepo.mergeDefaultTemplate(mSelectedLocale);
    String subject = mRepo.getProjectName() + " - "
            + getString(R.string.updated_x_translation, mSelectedLocale,
            LocaleString.getEnglishDisplay(mSelectedLocale));

    new ShareUtil(this).draftEmail(subject, xml, mRepo.settings.getProjectMail());
}