mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-02 11:46:55 +01:00
Share exported logs added (#4582)
This commit is contained in:
parent
469a1615db
commit
75b7b41fa0
@ -3,11 +3,21 @@ package de.danoeh.antennapod.activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import de.danoeh.antennapod.error.CrashReportWriter;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
@ -18,6 +28,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Displays the 'crash report' screen
|
||||
@ -63,12 +74,35 @@ public class BugReportActivity extends AppCompatActivity {
|
||||
filename.createNewFile();
|
||||
String cmd = "logcat -d -f " + filename.getAbsolutePath();
|
||||
Runtime.getRuntime().exec(cmd);
|
||||
Snackbar.make(findViewById(android.R.id.content),
|
||||
filename.getAbsolutePath(), Snackbar.LENGTH_SHORT).show();
|
||||
//share file
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_SEND);
|
||||
i.setType("text/*");
|
||||
String authString = getString(de.danoeh.antennapod.core.R.string.provider_authority);
|
||||
Uri fileUri = FileProvider.getUriForFile(this, authString, filename);
|
||||
i.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
||||
PackageManager pm = getPackageManager();
|
||||
List<ResolveInfo> resInfos = pm.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
for (ResolveInfo resolveInfo : resInfos) {
|
||||
String packageName = resolveInfo.activityInfo.packageName;
|
||||
grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
}
|
||||
String chooserTitle = getString(de.danoeh.antennapod.core.R.string.share_file_label);
|
||||
startActivity(Intent.createChooser(i, chooserTitle));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
int strResId = R.string.log_file_share_exception;
|
||||
Snackbar.make(findViewById(android.R.id.content), strResId, Snackbar.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Snackbar.make(findViewById(android.R.id.content), e.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,9 @@
|
||||
<string name="drawer_feed_counter_downloaded">Number of downloaded episodes</string>
|
||||
<string name="drawer_feed_counter_none">None</string>
|
||||
|
||||
<!-- Bug report activity -->
|
||||
<string name="log_file_share_exception">No compatible apps found</string>
|
||||
|
||||
<!-- Webview actions -->
|
||||
<string name="open_in_browser_label">Open in Browser</string>
|
||||
<string name="copy_url_label">Copy URL</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user