diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java
index 5bdba859b0..c44a755e5f 100644
--- a/app/src/main/java/eu/faircode/email/Helper.java
+++ b/app/src/main/java/eu/faircode/email/Helper.java
@@ -164,6 +164,9 @@ public class Helper {
static final String LICENSE_URI = "https://www.gnu.org/licenses/gpl-3.0.html";
static final String DONTKILL_URI = "https://dontkillmyapp.com/";
+ // https://developer.android.com/distribute/marketing-tools/linking-to-google-play#PerformingSearch
+ private static final String PLAY_STORE_SEARCH = "https://play.google.com/store/search";
+
static final Pattern EMAIL_ADDRESS
= Pattern.compile(
"[\\S]{1,256}" +
@@ -999,24 +1002,47 @@ public class Helper {
}
static void reportNoViewer(Context context, Intent intent) {
- StringBuilder sb = new StringBuilder();
+ View dview = LayoutInflater.from(context).inflate(R.layout.dialog_no_viewer, null);
+ TextView tvName = dview.findViewById(R.id.tvName);
+ TextView tvFullName = dview.findViewById(R.id.tvFullName);
+ TextView tvType = dview.findViewById(R.id.tvType);
String title = intent.getStringExtra(Intent.EXTRA_TITLE);
- if (TextUtils.isEmpty(title)) {
- Uri data = intent.getData();
- if (data == null)
- sb.append(intent.toString());
- else
- sb.append(data.toString());
- } else
- sb.append(title);
-
+ Uri data = intent.getData();
String type = intent.getType();
- if (!TextUtils.isEmpty(type))
- sb.append(' ').append(type);
+ String fullName = (data == null ? intent.toString() : data.toString());
+ String extension = (data == null ? null : getExtension(data.getLastPathSegment()));
+
+ tvName.setText(title == null ? fullName : title);
+ tvFullName.setText(fullName);
+ tvFullName.setVisibility(title == null ? View.GONE : View.VISIBLE);
+
+ tvType.setText(type == null ? "?" : type);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context)
+ .setView(dview)
+ .setNegativeButton(android.R.string.cancel, null);
+
+ if (hasPlayStore(context) && !TextUtils.isEmpty(extension)) {
+ builder.setNeutralButton(R.string.title_no_viewer_search, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ try {
+ Uri search = Uri.parse(PLAY_STORE_SEARCH)
+ .buildUpon()
+ .appendQueryParameter("q", extension)
+ .build();
+ Intent intent = new Intent(Intent.ACTION_VIEW, search);
+ context.startActivity(intent);
+ } catch (Throwable ex) {
+ Log.e(ex);
+ ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
+ }
+ }
+ });
+ }
- String message = context.getString(R.string.title_no_viewer, sb.toString());
- ToastEx.makeText(context, message, Toast.LENGTH_LONG).show();
+ builder.show();
}
static void excludeFromRecents(Context context) {
diff --git a/app/src/main/res/layout/dialog_no_viewer.xml b/app/src/main/res/layout/dialog_no_viewer.xml
new file mode 100644
index 0000000000..aed3ddb21c
--- /dev/null
+++ b/app/src/main/res/layout/dialog_no_viewer.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4cff6bbf0e..7dbb87895b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1050,7 +1050,10 @@
Your message wasn\'t delivered because the address couldn\'t be found.
No reply templates defined
- No viewer app available for %1$s
+ No viewer app available
+ Content name
+ Content type
+ Search app
No suitable audio recorder app available
No suitable camera app available
Storage access framework not available