add Share button to install history viewer
closes #1484 closes #1224 closes #70
This commit is contained in:
parent
0b3e52a924
commit
36c0505115
@ -21,9 +21,11 @@
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.support.v4.app.ShareCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
@ -31,6 +33,8 @@ import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
import org.fdroid.fdroid.data.RepoProvider;
|
||||
import org.fdroid.fdroid.installer.InstallHistoryService;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@ -81,6 +85,26 @@ public class InstallHistoryActivity extends AppCompatActivity {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_share:
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("Repos:\n");
|
||||
for (Repo repo : RepoProvider.Helper.all(this)) {
|
||||
if (repo.inuse) {
|
||||
stringBuilder.append("* ");
|
||||
stringBuilder.append(repo.address);
|
||||
stringBuilder.append('\n');
|
||||
}
|
||||
}
|
||||
ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this)
|
||||
.setStream(InstallHistoryService.LOG_URI)
|
||||
.setSubject(getString(R.string.send_history_csv, getString(R.string.app_name)))
|
||||
.setChooserTitle(R.string.send_install_history)
|
||||
.setText(stringBuilder.toString())
|
||||
.setType("text/plain");
|
||||
Intent intent = intentBuilder.getIntent();
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.menu_delete:
|
||||
getContentResolver().delete(InstallHistoryService.LOG_URI, null, null);
|
||||
TextView textView = findViewById(R.id.text);
|
||||
|
@ -1,7 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_share"
|
||||
android:icon="@drawable/ic_share_white"
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/menu_delete"
|
||||
android:icon="@android:drawable/ic_delete"
|
||||
android:icon="@drawable/ic_delete_white"
|
||||
android:title="@string/delete"/>
|
||||
</menu>
|
@ -24,6 +24,8 @@
|
||||
<string name="hide_all_notifications_summary">Prevent all actions from showing in the status bar and notification
|
||||
drawer.
|
||||
</string>
|
||||
<string name="send_install_history">Send Install History</string>
|
||||
<string name="send_history_csv">%s install history as CSV file</string>
|
||||
<string name="install_history">Install history</string>
|
||||
<string name="install_history_summary">View the private log of all installs and uninstalls</string>
|
||||
<string name="keep_install_history">Keep install history</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user