mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-02-19 15:48:19 -05:00
Merge branch 'share' into 'master'
Add createChooser for sharing installed apps + install history See merge request fdroid/fdroidclient!1494
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@@ -28,6 +29,7 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ShareCompat;
|
||||
@@ -137,6 +139,7 @@ public class InstallHistoryActivity extends AppCompatActivity {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.menu_share) {
|
||||
ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this);
|
||||
String title;
|
||||
if (showingInstallHistory) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("Repos:\n");
|
||||
@@ -147,22 +150,29 @@ public class InstallHistoryActivity extends AppCompatActivity {
|
||||
stringBuilder.append('\n');
|
||||
}
|
||||
}
|
||||
title = getString(R.string.send_install_history);
|
||||
intentBuilder
|
||||
.setText(stringBuilder.toString())
|
||||
.setStream(InstallHistoryService.LOG_URI)
|
||||
.setType("text/plain")
|
||||
.setSubject(getString(R.string.send_history_csv, appName))
|
||||
.setChooserTitle(R.string.send_install_history);
|
||||
.setChooserTitle(title);
|
||||
} else {
|
||||
title = getString(R.string.send_fdroid_metrics_report, appName);
|
||||
intentBuilder
|
||||
.setText(textView.getText())
|
||||
.setType("application/json")
|
||||
.setSubject(getString(R.string.send_fdroid_metrics_json, appName))
|
||||
.setChooserTitle(R.string.send_fdroid_metrics_report);
|
||||
.setChooserTitle(title);
|
||||
}
|
||||
Intent intent = intentBuilder.getIntent();
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivity(intent);
|
||||
try {
|
||||
Intent chooserIntent = Intent.createChooser(intent, title);
|
||||
startActivity(chooserIntent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Toast.makeText(this, R.string.no_handler_app_generic, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (itemId == R.id.menu_delete) {
|
||||
if (showingInstallHistory) {
|
||||
getContentResolver().delete(InstallHistoryService.LOG_URI, null, null);
|
||||
|
||||
@@ -19,11 +19,14 @@
|
||||
|
||||
package org.fdroid.fdroid.views.installed;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ShareCompat;
|
||||
@@ -118,12 +121,18 @@ public class InstalledAppsActivity extends AppCompatActivity {
|
||||
.append(app.installedVersionName).append('\n');
|
||||
}
|
||||
}
|
||||
String title = getString(R.string.send_installed_apps);
|
||||
ShareCompat.IntentBuilder intentBuilder = new ShareCompat.IntentBuilder(this)
|
||||
.setSubject(getString(R.string.send_installed_apps))
|
||||
.setChooserTitle(R.string.send_installed_apps)
|
||||
.setSubject(title)
|
||||
.setChooserTitle(title)
|
||||
.setText(stringBuilder.toString())
|
||||
.setType("text/csv");
|
||||
startActivity(intentBuilder.getIntent());
|
||||
try {
|
||||
Intent chooserIntent = Intent.createChooser(intentBuilder.getIntent(), title);
|
||||
startActivity(chooserIntent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Toast.makeText(this, R.string.no_handler_app_generic, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@@ -456,6 +456,7 @@ This often occurs with apps installed via Google Play or other sources, if they
|
||||
<string name="permissions">Permissions</string>
|
||||
<string name="apk_permissions_mismatch">App has unexpected permission: %s</string>
|
||||
<string name="no_handler_app">You don\'t have any available app that can handle %s.</string>
|
||||
<string name="no_handler_app_generic">You don\'t have any available app that can handle this.</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="use_pure_black_dark_theme">Use pure black background in dark theme</string>
|
||||
<string name="use_pure_black_dark_theme_summary">Recommended only for OLED screens.</string>
|
||||
|
||||
Reference in New Issue
Block a user