mirror of https://github.com/M66B/FairEmail.git
Report viewer error
This commit is contained in:
parent
b0036cad60
commit
4d3634b5ed
|
@ -460,12 +460,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
Log.i("Start intent=" + intent);
|
||||
Log.logExtras(intent);
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(this, intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(this, Log.formatThrowable(ex), Toast.LENGTH_LONG).show();
|
||||
Helper.reportNoViewer(this, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,15 +471,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
Log.i("Start intent=" + intent + " request=" + requestCode);
|
||||
Log.logExtras(intent);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
if (Helper.isTnef(intent.getType(), null))
|
||||
Helper.viewFAQ(this, 155);
|
||||
else
|
||||
Helper.reportNoViewer(this, intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(this, Log.formatThrowable(ex), Toast.LENGTH_LONG).show();
|
||||
Helper.reportNoViewer(this, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -501,9 +501,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
.putExtra(Settings.EXTRA_CHANNEL_ID, EntityAccount.getNotificationChannelId(account.id));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -300,9 +300,8 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|||
private void onActionShare() {
|
||||
try {
|
||||
context.startActivity(share);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, share);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, share, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1106,9 +1106,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
.putExtra(Settings.EXTRA_CHANNEL_ID, EntityFolder.getNotificationChannelId(folder.id));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3385,9 +3385,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
} else if (result instanceof Intent) {
|
||||
try {
|
||||
context.startActivity((Intent) result);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, (Intent) result);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, (Intent) result, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3890,9 +3889,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Intent intent = new Intent(Intent.ACTION_VIEW, lookupUri);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, intent, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4255,9 +4253,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(context, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4336,11 +4333,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
try {
|
||||
parentFragment.startActivityForResult(
|
||||
Helper.getChooser(context, pick), FragmentMessages.REQUEST_PICK_CONTACT);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(context, pick);
|
||||
} catch (Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex, false);
|
||||
Helper.reportNoViewer(context, pick, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5265,7 +5259,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.execute(context, owner, args, "view:cid");
|
||||
|
||||
else
|
||||
Helper.reportNoViewer(context, uri);
|
||||
Helper.reportNoViewer(context, uri, null);
|
||||
}
|
||||
|
||||
private void onMenuUnseen(final TupleMessageEx message) {
|
||||
|
@ -5638,12 +5632,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
EntityLog.log(context, "Sharing " + intent +
|
||||
" extras=" + TextUtils.join(", ", Log.getExtras(intent.getExtras())));
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R &&
|
||||
intent.resolveActivity(pm) == null) // system whitelisted
|
||||
Helper.reportNoViewer(context, intent);
|
||||
else
|
||||
context.startActivity(intent);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -157,12 +157,8 @@ public class FragmentBase extends Fragment {
|
|||
Log.i("Start intent=" + intent);
|
||||
Log.logExtras(intent);
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(getContext(), Log.formatThrowable(ex), Toast.LENGTH_LONG).show();
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,12 +168,8 @@ public class FragmentBase extends Fragment {
|
|||
Log.i("Start intent=" + intent + " request=" + requestCode);
|
||||
Log.logExtras(intent);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(getContext(), Log.formatThrowable(ex), Toast.LENGTH_LONG).show();
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2299,9 +2299,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
} else
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_RECORD_AUDIO);
|
||||
} catch (SecurityException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2771,12 +2770,9 @@ public class FragmentCompose extends FragmentBase {
|
|||
photoURI = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
|
||||
} catch (SecurityException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
// / java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
// java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -208,9 +208,8 @@ public class FragmentDialogBase extends DialogFragment {
|
|||
public void startActivity(Intent intent) {
|
||||
try {
|
||||
super.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,9 +217,8 @@ public class FragmentDialogBase extends DialogFragment {
|
|||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
try {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
} catch (Throwable ex) {
|
||||
Helper.reportNoViewer(getContext(), intent, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,10 +173,8 @@ public class FragmentGmail extends FragmentBase {
|
|||
null,
|
||||
null);
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
if (intent.resolveActivity(pm) == null) { // system whitelisted
|
||||
if (intent.resolveActivity(pm) == null) // system whitelisted
|
||||
Log.e("newChooseAccountIntent unavailable");
|
||||
Helper.reportNoViewer(getContext(), intent);
|
||||
}
|
||||
startActivityForResult(intent, ActivitySetup.REQUEST_CHOOSE_ACCOUNT);
|
||||
} catch (Throwable ex) {
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
|
|
|
@ -639,8 +639,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
try {
|
||||
getContext().startActivity(app);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
Helper.reportNoViewer(getContext(), app);
|
||||
Helper.reportNoViewer(getContext(), app, ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -714,7 +714,7 @@ public class Helper {
|
|||
if (isTnef(type, null))
|
||||
viewFAQ(context, 155);
|
||||
else
|
||||
reportNoViewer(context, intent);
|
||||
reportNoViewer(context, intent, null);
|
||||
else
|
||||
context.startActivity(intent);
|
||||
} else
|
||||
|
@ -741,9 +741,8 @@ public class Helper {
|
|||
else
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
reportNoViewer(context, intent);
|
||||
} catch (Throwable ex) {
|
||||
reportNoViewer(context, intent, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -774,12 +773,8 @@ public class Helper {
|
|||
if (task)
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(view);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
reportNoViewer(context, uri);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(context, Log.formatThrowable(ex, false), Toast.LENGTH_LONG).show();
|
||||
reportNoViewer(context, uri, ex);
|
||||
}
|
||||
} else {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
@ -807,12 +802,8 @@ public class Helper {
|
|||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
try {
|
||||
customTabsIntent.launchUrl(context, uri);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
Log.w(ex);
|
||||
reportNoViewer(context, uri);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(context, Log.formatThrowable(ex, false), Toast.LENGTH_LONG).show();
|
||||
reportNoViewer(context, uri, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1145,15 +1136,28 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
static void reportNoViewer(Context context, Uri uri) {
|
||||
reportNoViewer(context, new Intent().setData(uri));
|
||||
static void reportNoViewer(Context context, @NonNull Uri uri, @Nullable Throwable ex) {
|
||||
reportNoViewer(context, new Intent().setData(uri), ex);
|
||||
}
|
||||
|
||||
static void reportNoViewer(Context context, Intent intent) {
|
||||
static void reportNoViewer(Context context, @NonNull Intent intent, @Nullable Throwable ex) {
|
||||
if (ex != null) {
|
||||
if (ex instanceof ActivityNotFoundException && BuildConfig.PLAY_STORE_RELEASE)
|
||||
Log.w(ex);
|
||||
else
|
||||
Log.e(ex);
|
||||
}
|
||||
|
||||
if (Helper.isTnef(intent.getType(), null)) {
|
||||
Helper.viewFAQ(context, 155);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
TextView tvException = dview.findViewById(R.id.tvException);
|
||||
|
||||
String title = intent.getStringExtra(Intent.EXTRA_TITLE);
|
||||
Uri data = intent.getData();
|
||||
|
@ -1167,6 +1171,9 @@ public class Helper {
|
|||
|
||||
tvType.setText(type);
|
||||
|
||||
tvException.setText(ex == null ? null : ex.toString());
|
||||
tvException.setVisibility(ex == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||
.setView(dview)
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
|
@ -1662,7 +1669,7 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
static String toRoman(int value) {
|
||||
static String toRoman(int value) {
|
||||
if (value < 0 || value >= 4000)
|
||||
return Integer.toString(value);
|
||||
return ROMAN_1000[value / 1000] +
|
||||
|
@ -1671,7 +1678,7 @@ public class Helper {
|
|||
ROMAN_1[value % 10];
|
||||
}
|
||||
|
||||
static ActionMode.Callback getActionModeWrapper(Context context){
|
||||
static ActionMode.Callback getActionModeWrapper(Context context) {
|
||||
return new ActionMode.Callback() {
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
|
@ -1691,8 +1698,7 @@ public class Helper {
|
|||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
|
||||
reportNoViewer(context, intent, ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,5 +78,17 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTypeTitle" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvException"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Exception"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvType" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
Loading…
Reference in New Issue