Java Code Examples for com.danimahardhika.android.helpers.core.FileHelper#getUriFromFile()

The following examples show how to use com.danimahardhika.android.helpers.core.FileHelper#getUriFromFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PremiumRequestBuilderTask.java    From candybar with Apache License 2.0 6 votes vote down vote up
private Intent addIntentExtra(@NonNull Intent intent, String emailBody) {
    intent.setType("application/zip");

    if (CandyBarApplication.sZipPath != null) {
        File zip = new File(CandyBarApplication.sZipPath);
        if (zip.exists()) {
            Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
            if (uri == null) uri = Uri.fromFile(zip);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
    }

    String subject = "Rebuild Premium Request " + mContext.get().getResources().getString(R.string.app_name);

    intent.putExtra(Intent.EXTRA_EMAIL,
            new String[]{mContext.get().getResources().getString(R.string.dev_email)});
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, emailBody);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}
 
Example 2
Source File: WallpaperBoardCrashReport.java    From wallpaperboard with Apache License 2.0 6 votes vote down vote up
private Intent prepareUri(String deviceInfo, String stackTrace, Intent intent) {
    String crashLog = CrashReportHelper.buildCrashLog(this, getCacheDir(), stackTrace);
    boolean granted = PermissionHelper.isStorageGranted(this);
    if (crashLog != null) {
        Uri uri = FileHelper.getUriFromFile(this, getPackageName(), new File(crashLog));
        if (uri != null) {
            intent.putExtra(Intent.EXTRA_TEXT, deviceInfo +"\n");
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            return intent;
        } else {
            if (granted) {
                uri = Uri.fromFile(new File(crashLog));
                intent.putExtra(Intent.EXTRA_STREAM, uri);
                return intent;
            }
        }
    }

    intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + stackTrace);
    return intent;
}
 
Example 3
Source File: PremiumRequestBuilderTask.java    From candybar-library with Apache License 2.0 6 votes vote down vote up
private Intent addIntentExtra(@NonNull Intent intent, String emailBody) {
    intent.setType("message/rfc822");

    if (CandyBarApplication.sZipPath != null) {
        File zip = new File(CandyBarApplication.sZipPath);
        if (zip.exists()) {
            Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
            if (uri == null) uri = Uri.fromFile(zip);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
    }

    String subject = "Rebuild Premium Request " +mContext.get().getResources().getString(R.string.app_name);

    intent.putExtra(Intent.EXTRA_EMAIL,
            new String[]{mContext.get().getResources().getString(R.string.dev_email)});
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, emailBody);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}
 
Example 4
Source File: IconRequestBuilderTask.java    From candybar-library with Apache License 2.0 6 votes vote down vote up
private Intent addIntentExtra(@NonNull Intent intent, String emailBody) {
    intent.setType("message/rfc822");

    if (CandyBarApplication.sZipPath != null) {
        File zip = new File(CandyBarApplication.sZipPath);
        if (zip.exists()) {
            Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
            if (uri == null) uri = Uri.fromFile(zip);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
    }

    String subject = Preferences.get(mContext.get()).isPremiumRequest() ?
            "Premium Icon Request " : "Icon Request ";
    subject += mContext.get().getResources().getString(R.string.app_name);

    intent.putExtra(Intent.EXTRA_EMAIL,
            new String[]{mContext.get().getResources().getString(R.string.dev_email)});
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, emailBody);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}
 
Example 5
Source File: IconRequestBuilderTask.java    From candybar with Apache License 2.0 5 votes vote down vote up
private Intent addIntentExtra(@NonNull Intent intent, String emailBody) {
    intent.setType("application/zip");

    if (CandyBarApplication.sZipPath != null) {
        File zip = new File(CandyBarApplication.sZipPath);
        if (zip.exists()) {
            Uri uri = FileHelper.getUriFromFile(mContext.get(), mContext.get().getPackageName(), zip);
            if (uri == null) uri = Uri.fromFile(zip);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
    }

    String appName = mContext.get().getResources().getString(R.string.app_name);
    String regRequestSubject = appName + " Icon Request";
    String premRequestSubject = appName + " Premium Icon Request";

    if (mContext.get().getResources().getString(R.string.request_email_subject).length() > 0) {
        regRequestSubject = mContext.get().getResources().getString(R.string.request_email_subject);
    }

    if (mContext.get().getResources().getString(R.string.premium_request_email_subject).length() > 0) {
        premRequestSubject = mContext.get().getResources().getString(R.string.premium_request_email_subject);
    }

    String subject = Preferences.get(mContext.get()).isPremiumRequest() ?
            premRequestSubject : regRequestSubject;

    intent.putExtra(Intent.EXTRA_EMAIL,
            new String[]{mContext.get().getResources().getString(R.string.dev_email)});
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, emailBody);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}
 
Example 6
Source File: CandyBarCrashReport.java    From candybar with Apache License 2.0 5 votes vote down vote up
private Intent prepareUri(String deviceInfo, String stackTrace, Intent intent) {
    File crashLog = ReportBugsHelper.buildCrashLog(this, stackTrace);
    if (crashLog != null) {
        Uri uri = FileHelper.getUriFromFile(this, getPackageName(), crashLog);
        if (uri != null) {
            intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + "\n");
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            return intent;
        }
    }

    intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + stackTrace);
    return intent;
}
 
Example 7
Source File: CandyBarCrashReport.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
private Intent prepareUri(String deviceInfo, String stackTrace, Intent intent) {
    File crashLog = ReportBugsHelper.buildCrashLog(this, stackTrace);
    if (crashLog != null) {
        Uri uri = FileHelper.getUriFromFile(this, getPackageName(), crashLog);
        if (uri != null) {
            intent.putExtra(Intent.EXTRA_TEXT, deviceInfo +"\n");
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            return intent;
        }
    }

    intent.putExtra(Intent.EXTRA_TEXT, deviceInfo + stackTrace);
    return intent;
}