Refactoring

pull/187/head
M66B 5 years ago
parent 475814dad8
commit 297c09c129

@ -396,7 +396,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
super.startActivityForResult(intent, requestCode); super.startActivityForResult(intent, requestCode);
} catch (ActivityNotFoundException ex) { } catch (ActivityNotFoundException ex) {
Log.w(ex); Log.w(ex);
if (Helper.isTnef(intent.getType())) if (Helper.isTnef(intent.getType(), null))
Helper.viewFAQ(this, 155); Helper.viewFAQ(this, 155);
else else
ToastEx.makeText(this, getString(R.string.title_no_viewer, intent), Toast.LENGTH_LONG).show(); ToastEx.makeText(this, getString(R.string.title_no_viewer, intent), Toast.LENGTH_LONG).show();

@ -517,7 +517,7 @@ public class Helper {
// Check if viewer available // Check if viewer available
if (ris == null || ris.size() == 0) { if (ris == null || ris.size() == 0) {
if (isTnef(type)) if (isTnef(type, null))
viewFAQ(context, 155); viewFAQ(context, 155);
else { else {
String message = context.getString(R.string.title_no_viewer, String message = context.getString(R.string.title_no_viewer,
@ -530,10 +530,17 @@ public class Helper {
context.startActivity(intent); context.startActivity(intent);
} }
static boolean isTnef(String type) { static boolean isTnef(String type, String name) {
// https://en.wikipedia.org/wiki/Transport_Neutral_Encapsulation_Format // https://en.wikipedia.org/wiki/Transport_Neutral_Encapsulation_Format
return ("application/ms-tnef".equals(type) || if ("application/ms-tnef".equals(type) ||
"application/vnd.ms-tnef".equals(type)); "application/vnd.ms-tnef".equals(type))
return true;
if ("application/octet-stream".equals(type) &&
"winmail.dat".equals(name))
return true;
return false;
} }
static void view(Context context, Intent intent) { static void view(Context context, Intent intent) {

@ -1941,8 +1941,7 @@ public class MessageHelper {
downloadAttachment(context, index, local); downloadAttachment(context, index, local);
if (Helper.isTnef(local.type) || if (Helper.isTnef(local.type, local.name))
("application/octet-stream".equals(local.type) && "winmail.dat".equals(local.name)))
decodeTNEF(context, local); decodeTNEF(context, local);
} }

Loading…
Cancel
Save