2017-12-20 14:54:05 +01:00
|
|
|
/*
|
2018-03-28 15:10:51 +02:00
|
|
|
* \copyright Copyright (c) 2016-2018 Governikus GmbH & Co. KG, Germany
|
2017-12-20 14:54:05 +01:00
|
|
|
*/
|
|
|
|
|
2017-07-03 09:30:10 +02:00
|
|
|
package com.governikus.ausweisapp2;
|
|
|
|
|
2018-03-28 15:10:51 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
2017-07-03 09:33:28 +02:00
|
|
|
import android.app.Activity;
|
2018-03-28 15:10:51 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2017-07-03 09:33:28 +02:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2017-07-03 09:30:10 +02:00
|
|
|
|
2018-03-28 15:10:51 +02:00
|
|
|
public final class ShareUtil
|
2017-07-03 09:30:10 +02:00
|
|
|
{
|
2018-03-28 15:10:51 +02:00
|
|
|
private static final String LOG_TAG = AusweisApp2Service.LOG_TAG;
|
|
|
|
|
|
|
|
private ShareUtil()
|
|
|
|
{
|
|
|
|
}
|
2017-07-03 09:33:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
public static void shareText(Context ctx, final String text, final String chooserTitle)
|
2017-07-03 09:30:10 +02:00
|
|
|
{
|
|
|
|
Intent shareData = new Intent();
|
|
|
|
shareData.setType("text/plain");
|
|
|
|
shareData.setAction(Intent.ACTION_SEND);
|
|
|
|
shareData.putExtra(Intent.EXTRA_TEXT, text);
|
|
|
|
ctx.startActivity(Intent.createChooser(shareData, chooserTitle));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-03 09:33:28 +02:00
|
|
|
public static void shareLog(Activity activity, final String email, final String subject, final String msg, final String logFilePath, final String chooserTitle)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Intent shareData = new Intent();
|
|
|
|
shareData.setType("message/rfc822");
|
|
|
|
shareData.setAction(Intent.ACTION_SEND);
|
|
|
|
shareData.putExtra(Intent.EXTRA_EMAIL, new String[] {email});
|
|
|
|
shareData.putExtra(Intent.EXTRA_SUBJECT, subject);
|
|
|
|
shareData.putExtra(Intent.EXTRA_TEXT, msg);
|
|
|
|
shareData.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(logFilePath)));
|
|
|
|
activity.startActivity(Intent.createChooser(shareData, chooserTitle));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2018-03-28 15:10:51 +02:00
|
|
|
Log.e(LOG_TAG, "Error sharing log file", e);
|
2017-07-03 09:33:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-03 09:30:10 +02:00
|
|
|
}
|