mirror of https://github.com/M66B/FairEmail.git
Added resolution for no viewer app
This commit is contained in:
parent
8620fb243e
commit
4f42f5ced4
|
@ -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()));
|
||||
|
||||
String message = context.getString(R.string.title_no_viewer, sb.toString());
|
||||
ToastEx.makeText(context, message, Toast.LENGTH_LONG).show();
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
static void excludeFromRecents(Context context) {
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<eu.faircode.email.ScrollViewEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp"
|
||||
android:scrollbarStyle="outsideOverlay">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvCaption"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/twotone_warning_24"
|
||||
android:drawablePadding="6dp"
|
||||
android:drawableTint="?attr/colorWarning"
|
||||
android:text="@string/title_no_viewer_caption"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvNameTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/title_no_viewer_name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvCaption" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNameTitle" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvFullName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="Full name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvName" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvTypeTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/title_no_viewer_type"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvFullName" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvType"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Type"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTypeTitle" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
|
@ -1050,7 +1050,10 @@
|
|||
<string name="title_hard_bounce_text" translatable="false">Your message wasn\'t delivered because the address couldn\'t be found.</string>
|
||||
|
||||
<string name="title_no_answers">No reply templates defined</string>
|
||||
<string name="title_no_viewer">No viewer app available for %1$s</string>
|
||||
<string name="title_no_viewer_caption">No viewer app available</string>
|
||||
<string name="title_no_viewer_name">Content name</string>
|
||||
<string name="title_no_viewer_type">Content type</string>
|
||||
<string name="title_no_viewer_search">Search app</string>
|
||||
<string name="title_no_recorder">No suitable audio recorder app available</string>
|
||||
<string name="title_no_camera">No suitable camera app available</string>
|
||||
<string name="title_no_saf">Storage access framework not available</string>
|
||||
|
|
Loading…
Reference in New Issue