show file intent after export
This commit is contained in:
@@ -3,9 +3,12 @@ package net.headlezz.notificationlogger.preferences;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@@ -17,6 +20,7 @@ import android.support.v7.app.AlertDialog;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -167,17 +171,38 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
|||||||
if (progressDialog != null && progressDialog.isShowing())
|
if (progressDialog != null && progressDialog.isShowing())
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
String message;
|
|
||||||
if (path.isEmpty())
|
if (path.isEmpty()) {
|
||||||
message = getContext().getString(R.string.pref_export_snack_failed);
|
String message = getContext().getString(R.string.pref_export_snack_failed);
|
||||||
else
|
Snackbar snack = Snackbar.make(getActivity().findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT);
|
||||||
message = String.format(getContext().getString(R.string.pref_export_snack_success), path);
|
snack.show();
|
||||||
Snackbar.make(getActivity().findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT).show();
|
} else {
|
||||||
|
String message = String.format(getContext().getString(R.string.pref_export_snack_success), path);
|
||||||
|
Snackbar snack = Snackbar.make(getActivity().findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT);
|
||||||
|
snack.setAction(R.string.pref_export_snack_action, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showFolder();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
snack.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showFolder() {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath());
|
||||||
|
intent.setDataAndType(uri, "file/*");
|
||||||
|
startActivity(Intent.createChooser(intent, getContext().getString(R.string.pref_export_snack_show_chooser_title)));
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(getContext(), R.string.pref_export_snack_show_activity_not_found, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void askClearDatabase() {
|
private void askClearDatabase() {
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setTitle(R.string.pref_clear_database_dialog_title)
|
.setTitle(R.string.pref_clear_database_dialog_title)
|
||||||
|
|||||||
@@ -80,6 +80,9 @@
|
|||||||
<string name="share_title">Share Notification</string>
|
<string name="share_title">Share Notification</string>
|
||||||
<string name="notification_list_frag_blacklist_snack">%s blacklisted.</string>
|
<string name="notification_list_frag_blacklist_snack">%s blacklisted.</string>
|
||||||
<string name="notification_list_frag_blacklist_snack_action">Undo</string>
|
<string name="notification_list_frag_blacklist_snack_action">Undo</string>
|
||||||
|
<string name="pref_export_snack_action">Show</string>
|
||||||
|
<string name="pref_export_snack_show_chooser_title">Open folder</string>
|
||||||
|
<string name="pref_export_snack_show_activity_not_found">No file browser installed.</string>
|
||||||
|
|
||||||
<string-array name="notification_list_options">
|
<string-array name="notification_list_options">
|
||||||
<item>Show more info</item>
|
<item>Show more info</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user