mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
New preference setting to add buttons to attach images or videos which is needed to work around a bug in Gallery 3D. Buttons are enabled by default if a buggy Gallery 3D version is found.
Thanks to dman13 for providing the work-around and analysing the bug. Fixes issue 1186
This commit is contained in:
parent
8baedd0966
commit
582c3f82b8
@ -36,4 +36,16 @@
|
|||||||
android:title="@string/choose_identity"
|
android:title="@string/choose_identity"
|
||||||
android:icon="@drawable/ic_menu_cc"
|
android:icon="@drawable/ic_menu_cc"
|
||||||
/>
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/add_attachment_image"
|
||||||
|
android:title="@string/add_attachment_action_image"
|
||||||
|
android:icon="@drawable/ic_menu_attachment"
|
||||||
|
android:visible="false"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/add_attachment_video"
|
||||||
|
android:title="@string/add_attachment_action_video"
|
||||||
|
android:icon="@drawable/ic_menu_attachment"
|
||||||
|
android:visible="false"
|
||||||
|
/>
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -96,6 +96,8 @@
|
|||||||
<string name="add_cc_bcc_action">Add Cc/Bcc</string>
|
<string name="add_cc_bcc_action">Add Cc/Bcc</string>
|
||||||
<string name="edit_subject_action">Edit subject</string>
|
<string name="edit_subject_action">Edit subject</string>
|
||||||
<string name="add_attachment_action">Add attachment</string>
|
<string name="add_attachment_action">Add attachment</string>
|
||||||
|
<string name="add_attachment_action_image">Add attachment (Image)</string>
|
||||||
|
<string name="add_attachment_action_video">Add attachment (Video)</string>
|
||||||
<string name="dump_settings_action">Dump settings</string>
|
<string name="dump_settings_action">Dump settings</string>
|
||||||
<string name="empty_trash_action">Empty Trash</string>
|
<string name="empty_trash_action">Empty Trash</string>
|
||||||
<string name="expunge_action">Expunge</string>
|
<string name="expunge_action">Expunge</string>
|
||||||
@ -753,4 +755,14 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<string name="font_size_webview_large">Larger</string>
|
<string name="font_size_webview_large">Larger</string>
|
||||||
<string name="font_size_webview_larger">Largest</string>
|
<string name="font_size_webview_larger">Largest</string>
|
||||||
|
|
||||||
|
<!-- Note: Contains references to preferences_action and misc_preferences_attachment_title -->
|
||||||
|
<string name="message_compose_buggy_gallery">Check \"Settings\" -> \"Use Gallery bug work-around\" to be able to attach images or videos using Gallery 3D.</string>
|
||||||
|
|
||||||
|
<!-- Note: Contains references to add_attachment_action_image and add_attachment_action_video -->
|
||||||
|
<string name="message_compose_use_workaround">Use \"Add attachment (Image)\" or \"Add attachment (Video)\" to attach images or videos with Gallery 3D.</string>
|
||||||
|
|
||||||
|
<string name="miscellaneous_preferences">Miscellaneous</string>
|
||||||
|
<string name="misc_preferences_attachment_title">Use Gallery bug work-around</string>
|
||||||
|
<string name="misc_preferences_attachment_description">Show buttons to add image/video attachments (to work around a Gallery 3D bug)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -93,6 +93,15 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/miscellaneous_preferences" android:key="misc_preferences">
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="use_gallery_bug_workaround"
|
||||||
|
android:title="@string/misc_preferences_attachment_title"
|
||||||
|
android:summary="@string/misc_preferences_attachment_description" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/debug_preferences" android:key="debug_preferences">
|
<PreferenceCategory android:title="@string/debug_preferences" android:key="debug_preferences">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@ -6,7 +6,9 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
@ -77,6 +79,9 @@ public class K9 extends Application
|
|||||||
private static boolean mMeasureAccounts = true;
|
private static boolean mMeasureAccounts = true;
|
||||||
private static boolean mCountSearchMessages = true;
|
private static boolean mCountSearchMessages = true;
|
||||||
|
|
||||||
|
private static boolean useGalleryBugWorkaround = false;
|
||||||
|
private static boolean galleryBuggy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We use WebSettings.getBlockNetworkLoads() to prevent the WebView that displays email
|
* We use WebSettings.getBlockNetworkLoads() to prevent the WebView that displays email
|
||||||
* bodies from loading external resources over the network. Unfortunately this method
|
* bodies from loading external resources over the network. Unfortunately this method
|
||||||
@ -304,6 +309,7 @@ public class K9 extends Application
|
|||||||
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
|
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
|
||||||
editor.putBoolean("messageListTouchable",mMessageListTouchable);
|
editor.putBoolean("messageListTouchable",mMessageListTouchable);
|
||||||
editor.putInt("theme", theme);
|
editor.putInt("theme", theme);
|
||||||
|
editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround);
|
||||||
|
|
||||||
fontSizes.save(editor);
|
fontSizes.save(editor);
|
||||||
}
|
}
|
||||||
@ -313,6 +319,9 @@ public class K9 extends Application
|
|||||||
{
|
{
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
app = this;
|
app = this;
|
||||||
|
|
||||||
|
galleryBuggy = checkForBuggyGallery();
|
||||||
|
|
||||||
Preferences prefs = Preferences.getPreferences(this);
|
Preferences prefs = Preferences.getPreferences(this);
|
||||||
SharedPreferences sprefs = prefs.getPreferences();
|
SharedPreferences sprefs = prefs.getPreferences();
|
||||||
DEBUG = sprefs.getBoolean("enableDebugLogging", false);
|
DEBUG = sprefs.getBoolean("enableDebugLogging", false);
|
||||||
@ -324,6 +333,7 @@ public class K9 extends Application
|
|||||||
mMessageListStars = sprefs.getBoolean("messageListStars",true);
|
mMessageListStars = sprefs.getBoolean("messageListStars",true);
|
||||||
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
|
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
|
||||||
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
|
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
|
||||||
|
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
|
||||||
|
|
||||||
fontSizes.load(sprefs);
|
fontSizes.load(sprefs);
|
||||||
|
|
||||||
@ -546,4 +556,42 @@ public class K9 extends Application
|
|||||||
{
|
{
|
||||||
mCountSearchMessages = countSearchMessages;
|
mCountSearchMessages = countSearchMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean useGalleryBugWorkaround()
|
||||||
|
{
|
||||||
|
return useGalleryBugWorkaround;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUseGalleryBugWorkaround(boolean useGalleryBugWorkaround)
|
||||||
|
{
|
||||||
|
K9.useGalleryBugWorkaround = useGalleryBugWorkaround;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGalleryBuggy()
|
||||||
|
{
|
||||||
|
return galleryBuggy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this system contains a buggy Gallery 3D package.
|
||||||
|
*
|
||||||
|
* We have to work around the fact that those Gallery versions won't show
|
||||||
|
* any images or videos when the pick intent is used with a MIME type other
|
||||||
|
* than image/* or video/*. See issue 1186.
|
||||||
|
*
|
||||||
|
* @return true, if a buggy Gallery 3D package was found. False, otherwise.
|
||||||
|
*/
|
||||||
|
private boolean checkForBuggyGallery()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PackageInfo pi = getPackageManager().getPackageInfo("com.cooliris.media", 0);
|
||||||
|
|
||||||
|
return (pi.versionCode == 30682);
|
||||||
|
}
|
||||||
|
catch (NameNotFoundException e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,10 +909,34 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
* Kick off a picker for whatever kind of MIME types we'll accept and let Android take over.
|
* Kick off a picker for whatever kind of MIME types we'll accept and let Android take over.
|
||||||
*/
|
*/
|
||||||
private void onAddAttachment()
|
private void onAddAttachment()
|
||||||
|
{
|
||||||
|
if (K9.isGalleryBuggy())
|
||||||
|
{
|
||||||
|
if (K9.useGalleryBugWorkaround())
|
||||||
|
{
|
||||||
|
Toast.makeText(MessageCompose.this,
|
||||||
|
getString(R.string.message_compose_use_workaround),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.makeText(MessageCompose.this,
|
||||||
|
getString(R.string.message_compose_buggy_gallery),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAddAttachment2(K9.ACCEPTABLE_ATTACHMENT_SEND_TYPES[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kick off a picker for the specified MIME type and let Android take over.
|
||||||
|
*/
|
||||||
|
private void onAddAttachment2(final String mime_type)
|
||||||
{
|
{
|
||||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
i.setType(K9.ACCEPTABLE_ATTACHMENT_SEND_TYPES[0]);
|
i.setType(mime_type);
|
||||||
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_ATTACHMENT);
|
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_ATTACHMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,6 +1125,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
case R.id.add_attachment:
|
case R.id.add_attachment:
|
||||||
onAddAttachment();
|
onAddAttachment();
|
||||||
break;
|
break;
|
||||||
|
case R.id.add_attachment_image:
|
||||||
|
onAddAttachment2("image/*");
|
||||||
|
break;
|
||||||
|
case R.id.add_attachment_video:
|
||||||
|
onAddAttachment2("video/*");
|
||||||
|
break;
|
||||||
case R.id.choose_identity:
|
case R.id.choose_identity:
|
||||||
onChooseIdentity();
|
onChooseIdentity();
|
||||||
break;
|
break;
|
||||||
@ -1131,6 +1161,26 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
getMenuInflater().inflate(R.menu.message_compose_option, menu);
|
getMenuInflater().inflate(R.menu.message_compose_option, menu);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show the menu items "Add attachment (Image)" and "Add attachment (Video)"
|
||||||
|
* if the work-around for the Gallery bug is enabled (see Issue 1186).
|
||||||
|
*/
|
||||||
|
int found = 0;
|
||||||
|
for (int i = menu.size() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
MenuItem item = menu.getItem(i);
|
||||||
|
int id = item.getItemId();
|
||||||
|
if ((id == R.id.add_attachment_image) ||
|
||||||
|
(id == R.id.add_attachment_video))
|
||||||
|
{
|
||||||
|
item.setVisible(K9.useGalleryBugWorkaround());
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We found all the menu items we were looking for. So stop here.
|
||||||
|
if (found == 2) break;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
|
|
||||||
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
|
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
|
||||||
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
|
||||||
|
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
|
||||||
private ListPreference mTheme;
|
private ListPreference mTheme;
|
||||||
private ListPreference mDateFormat;
|
private ListPreference mDateFormat;
|
||||||
private ListPreference mBackgroundOps;
|
private ListPreference mBackgroundOps;
|
||||||
@ -46,6 +47,7 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
private CheckBoxPreference mTouchable;
|
private CheckBoxPreference mTouchable;
|
||||||
private CheckBoxPreference mMeasureAccounts;
|
private CheckBoxPreference mMeasureAccounts;
|
||||||
private CheckBoxPreference mCountSearch;
|
private CheckBoxPreference mCountSearch;
|
||||||
|
private CheckBoxPreference mUseGalleryBugWorkaround;
|
||||||
|
|
||||||
|
|
||||||
private String initBackgroundOps;
|
private String initBackgroundOps;
|
||||||
@ -158,6 +160,9 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
|
|
||||||
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
|
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
|
||||||
mCountSearch.setChecked(K9.countSearchMessages());
|
mCountSearch.setChecked(K9.countSearchMessages());
|
||||||
|
|
||||||
|
mUseGalleryBugWorkaround = (CheckBoxPreference)findPreference(PREFERENCE_GALLERY_BUG_WORKAROUND);
|
||||||
|
mUseGalleryBugWorkaround.setChecked(K9.useGalleryBugWorkaround());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -184,6 +189,8 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
|
||||||
K9.setCountSearchMessages(mCountSearch.isChecked());
|
K9.setCountSearchMessages(mCountSearch.isChecked());
|
||||||
|
|
||||||
|
K9.setUseGalleryBugWorkaround(mUseGalleryBugWorkaround.isChecked());
|
||||||
|
|
||||||
Editor editor = preferences.edit();
|
Editor editor = preferences.edit();
|
||||||
K9.save(editor);
|
K9.save(editor);
|
||||||
DateFormatter.setDateFormat(editor, mDateFormat.getValue());
|
DateFormatter.setDateFormat(editor, mDateFormat.getValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user