1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fixes issue 1522

Added option to automatically show images in message view (always, if sender is in contacts, never).
Patch by paulkilroy (thanks!)

Includes bugfix for the "Show pictures" on orientation change code introduced earlier.
This commit is contained in:
cketti 2010-08-07 22:38:08 +00:00
parent 9d45470b40
commit 43fb202d43
6 changed files with 209 additions and 98 deletions

View File

@ -129,9 +129,9 @@
<string-array name="account_settings_folder_display_mode_entries">
<item>@string/account_settings_folder_display_mode_all</item>
<item>@string/account_settings_folder_display_mode_first_class</item>
<item>@string/account_settings_folder_display_mode_first_and_second_class</item>
<item>@string/account_settings_folder_display_mode_not_second_class</item>
<item>@string/account_settings_folder_display_mode_first_class</item>
<item>@string/account_settings_folder_display_mode_first_and_second_class</item>
<item>@string/account_settings_folder_display_mode_not_second_class</item>
</string-array>
<string-array name="account_settings_folder_display_mode_values">
@ -143,8 +143,8 @@
<string-array name="account_settings_hide_buttons_entries">
<item>@string/account_settings_hide_buttons_never</item>
<item>@string/account_settings_hide_buttons_keyboard_avail</item>
<item>@string/account_settings_hide_buttons_always</item>
<item>@string/account_settings_hide_buttons_keyboard_avail</item>
<item>@string/account_settings_hide_buttons_always</item>
</string-array>
<string-array name="account_settings_hide_buttons_values">
@ -155,8 +155,8 @@
<string-array name="account_settings_hide_move_buttons_entries">
<item>@string/account_settings_hide_buttons_never</item>
<item>@string/account_settings_hide_buttons_keyboard_avail</item>
<item>@string/account_settings_hide_buttons_always</item>
<item>@string/account_settings_hide_buttons_keyboard_avail</item>
<item>@string/account_settings_hide_buttons_always</item>
</string-array>
<string-array name="account_settings_hide_move_buttons_values">
@ -165,10 +165,22 @@
<item>ALWAYS</item>
</string-array>
<string-array name="account_settings_show_pictures_entries">
<item>@string/account_settings_show_pictures_never</item>
<item>@string/account_settings_show_pictures_only_from_contacts</item>
<item>@string/account_settings_show_pictures_always</item>
</string-array>
<string-array name="account_settings_show_pictures_values">
<item>NEVER</item>
<item>ONLY_FROM_CONTACTS</item>
<item>ALWAYS</item>
</string-array>
<string-array name="account_settings_searchable_entries">
<item>@string/account_settings_searchable_all</item>
<item>@string/account_settings_searchable_displayable</item>
<item>@string/account_settings_searchable_none</item>
<item>@string/account_settings_searchable_displayable</item>
<item>@string/account_settings_searchable_none</item>
</string-array>
<string-array name="account_settings_searchable_values">
@ -177,12 +189,12 @@
<item>NONE</item>
</string-array>
<string-array name="account_settings_folder_sync_mode_entries">
<string-array name="account_settings_folder_sync_mode_entries">
<item>@string/account_settings_folder_sync_mode_all</item>
<item>@string/account_settings_folder_sync_mode_first_class</item>
<item>@string/account_settings_folder_sync_mode_first_and_second_class</item>
<item>@string/account_settings_folder_sync_mode_not_second_class</item>
<item>@string/account_settings_folder_sync_mode_none</item>
<item>@string/account_settings_folder_sync_mode_first_class</item>
<item>@string/account_settings_folder_sync_mode_first_and_second_class</item>
<item>@string/account_settings_folder_sync_mode_not_second_class</item>
<item>@string/account_settings_folder_sync_mode_none</item>
</string-array>
<string-array name="account_settings_folder_sync_mode_values">
@ -195,10 +207,10 @@
<string-array name="account_settings_folder_push_mode_entries">
<item>@string/account_settings_folder_push_mode_all</item>
<item>@string/account_settings_folder_push_mode_first_class</item>
<item>@string/account_settings_folder_push_mode_first_and_second_class</item>
<item>@string/account_settings_folder_push_mode_not_second_class</item>
<item>@string/account_settings_folder_push_mode_none</item>
<item>@string/account_settings_folder_push_mode_first_class</item>
<item>@string/account_settings_folder_push_mode_first_and_second_class</item>
<item>@string/account_settings_folder_push_mode_not_second_class</item>
<item>@string/account_settings_folder_push_mode_none</item>
</string-array>
<string-array name="account_settings_folder_push_mode_values">
@ -210,13 +222,13 @@
</string-array>
<string-array name="account_settings_push_limit_entries">
<item>@string/account_setup_push_limit_10</item>
<item>@string/account_setup_push_limit_25</item>
<item>@string/account_setup_push_limit_50</item>
<item>@string/account_setup_push_limit_100</item>
<item>@string/account_setup_push_limit_250</item>
<item>@string/account_setup_push_limit_500</item>
<item>@string/account_setup_push_limit_1000</item>
<item>@string/account_setup_push_limit_10</item>
<item>@string/account_setup_push_limit_25</item>
<item>@string/account_setup_push_limit_50</item>
<item>@string/account_setup_push_limit_100</item>
<item>@string/account_setup_push_limit_250</item>
<item>@string/account_setup_push_limit_500</item>
<item>@string/account_setup_push_limit_1000</item>
</string-array>
<string-array name="account_settings_push_limit_values">
@ -231,9 +243,9 @@
<string-array name="account_settings_folder_target_mode_entries">
<item>@string/account_settings_folder_target_mode_all</item>
<item>@string/account_settings_folder_target_mode_first_class</item>
<item>@string/account_settings_folder_target_mode_first_and_second_class</item>
<item>@string/account_settings_folder_target_mode_not_second_class</item>
<item>@string/account_settings_folder_target_mode_first_class</item>
<item>@string/account_settings_folder_target_mode_first_and_second_class</item>
<item>@string/account_settings_folder_target_mode_not_second_class</item>
</string-array>
<string-array name="account_settings_folder_target_mode_values">
@ -244,9 +256,9 @@
</string-array>
<string-array name="folder_settings_folder_display_mode_entries">
<item>@string/folder_settings_folder_display_mode_normal</item>
<item>@string/folder_settings_folder_display_mode_first_class</item>
<item>@string/folder_settings_folder_display_mode_second_class</item>
<item>@string/folder_settings_folder_display_mode_normal</item>
<item>@string/folder_settings_folder_display_mode_first_class</item>
<item>@string/folder_settings_folder_display_mode_second_class</item>
</string-array>
<string-array name="folder_settings_folder_display_mode_values">
@ -256,31 +268,31 @@
</string-array>
<string-array name="folder_settings_folder_sync_mode_entries">
<item>@string/folder_settings_folder_sync_mode_normal</item>
<item>@string/folder_settings_folder_sync_mode_first_class</item>
<item>@string/folder_settings_folder_sync_mode_second_class</item>
<item>@string/folder_settings_folder_sync_mode_inherited</item>
<item>@string/folder_settings_folder_sync_mode_normal</item>
<item>@string/folder_settings_folder_sync_mode_first_class</item>
<item>@string/folder_settings_folder_sync_mode_second_class</item>
<item>@string/folder_settings_folder_sync_mode_inherited</item>
</string-array>
<string-array name="folder_settings_folder_sync_mode_values">
<item>NO_CLASS</item>
<item>FIRST_CLASS</item>
<item>SECOND_CLASS</item>
<item>INHERITED</item>
<item>NO_CLASS</item>
<item>FIRST_CLASS</item>
<item>SECOND_CLASS</item>
<item>INHERITED</item>
</string-array>
<string-array name="folder_settings_folder_push_mode_entries">
<item>@string/folder_settings_folder_push_mode_normal</item>
<item>@string/folder_settings_folder_push_mode_first_class</item>
<item>@string/folder_settings_folder_push_mode_second_class</item>
<item>@string/folder_settings_folder_push_mode_inherited</item>
<item>@string/folder_settings_folder_push_mode_normal</item>
<item>@string/folder_settings_folder_push_mode_first_class</item>
<item>@string/folder_settings_folder_push_mode_second_class</item>
<item>@string/folder_settings_folder_push_mode_inherited</item>
</string-array>
<string-array name="folder_settings_folder_push_mode_values">
<item>NO_CLASS</item>
<item>FIRST_CLASS</item>
<item>SECOND_CLASS</item>
<item>INHERITED</item>
<item>NO_CLASS</item>
<item>FIRST_CLASS</item>
<item>SECOND_CLASS</item>
<item>INHERITED</item>
</string-array>
<string-array name="account_setup_delete_policy_entries">
@ -296,15 +308,15 @@
</string-array>
<string-array name="account_setup_expunge_policy_entries">
<item>@string/account_setup_expunge_policy_immediately</item>
<item>@string/account_setup_expunge_policy_on_poll</item>
<item>@string/account_setup_expunge_policy_manual</item>
<item>@string/account_setup_expunge_policy_immediately</item>
<item>@string/account_setup_expunge_policy_on_poll</item>
<item>@string/account_setup_expunge_policy_manual</item>
</string-array>
<string-array name="account_setup_expunge_policy_values">
<item>EXPUNGE_IMMEDIATELY</item>
<item>EXPUNGE_ON_POLL</item>
<item>EXPUNGE_MANUALLY</item>
<string-array name="account_setup_expunge_policy_values">
<item>EXPUNGE_IMMEDIATELY</item>
<item>EXPUNGE_ON_POLL</item>
<item>EXPUNGE_MANUALLY</item>
</string-array>
<string-array name="settings_language_entries">
@ -493,20 +505,19 @@
</string-array>
<string-array name="background_ops_values">
<item>WHEN_CHECKED</item>
<item>WHEN_CHECKED_AUTO_SYNC</item>
<item>ALWAYS</item>
<item>NEVER</item>
<item>WHEN_CHECKED</item>
<item>WHEN_CHECKED_AUTO_SYNC</item>
<item>ALWAYS</item>
<item>NEVER</item>
</string-array>
<string-array name="date_formats">
<item>@string/date_format_short</item>
<item>@string/date_format_medium</item>
<item>@string/date_format_common</item>
<item>@string/date_format_iso8601</item>
<item>@string/date_format_short</item>
<item>@string/date_format_medium</item>
<item>@string/date_format_common</item>
<item>@string/date_format_iso8601</item>
</string-array>
<string-array name="font_entries">
<item>@string/font_size_tiniest</item>
<item>@string/font_size_tiny</item>
@ -548,15 +559,15 @@
</string-array>
<string-array name="idle_refresh_period_entries">
<item>@string/idle_refresh_period_1min</item>
<item>@string/idle_refresh_period_2min</item>
<item>@string/idle_refresh_period_3min</item>
<item>@string/idle_refresh_period_6min</item>
<item>@string/idle_refresh_period_12min</item>
<item>@string/idle_refresh_period_24min</item>
<item>@string/idle_refresh_period_36min</item>
<item>@string/idle_refresh_period_48min</item>
<item>@string/idle_refresh_period_60min</item>
<item>@string/idle_refresh_period_1min</item>
<item>@string/idle_refresh_period_2min</item>
<item>@string/idle_refresh_period_3min</item>
<item>@string/idle_refresh_period_6min</item>
<item>@string/idle_refresh_period_12min</item>
<item>@string/idle_refresh_period_24min</item>
<item>@string/idle_refresh_period_36min</item>
<item>@string/idle_refresh_period_48min</item>
<item>@string/idle_refresh_period_60min</item>
</string-array>
<string-array name="idle_refresh_period_values">

View File

@ -505,6 +505,11 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_enable_move_buttons_summary">Show the Archive, Move, and Spam buttons.</string>
<string name="account_settings_hide_move_buttons_label">Scroll move buttons</string>
<string name="account_settings_show_pictures_label">Show pictures automatically</string>
<string name="account_settings_show_pictures_never">Never</string>
<string name="account_settings_show_pictures_only_from_contacts">Only from contacts</string>
<string name="account_settings_show_pictures_always">Always</string>
<string name="account_settings_composition">Writing messages</string>
<string name="account_settings_sync">Syncing folders</string>
<string name="account_settings_folders">Folders</string>

View File

@ -30,9 +30,10 @@
android:key="account_default"
android:title="@string/account_settings_default_label"
android:summary="@string/account_settings_default_summary" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_message_lists">
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_message_lists">
<ListPreference
android:key="account_display_count"
@ -45,14 +46,14 @@
android:key="chip_color"
android:singleLine="true"
android:title="@string/account_settings_color_label"
android:summary="@string/account_settings_color_summary"
/>
android:summary="@string/account_settings_color_summary" />
<Preference
android:key="led_color"
android:singleLine="true"
android:title="@string/account_settings_led_color_label"
android:summary="@string/account_settings_led_color_summary"
/>
android:summary="@string/account_settings_led_color_summary" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_message_view">
@ -78,9 +79,17 @@
android:entryValues="@array/account_settings_hide_move_buttons_values"
android:dialogTitle="@string/account_settings_hide_move_buttons_label" />
<ListPreference
android:key="show_pictures_enum"
android:title="@string/account_settings_show_pictures_label"
android:entries="@array/account_settings_show_pictures_entries"
android:entryValues="@array/account_settings_show_pictures_values"
android:dialogTitle="@string/account_settings_show_pictures_label" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_sync">
<ListPreference
android:key="account_check_frequency"
android:title="@string/account_settings_mail_check_frequency_label"
@ -135,12 +144,11 @@
android:title="@string/account_settings_sync_remote_deletetions_label"
android:defaultValue="true"
android:summary="@string/account_settings_sync_remote_deletetions_summary" />
<PreferenceScreen
android:key="incoming"
android:title="@string/account_settings_incoming_label"
android:summary="@string/account_settings_incoming_summary"
/>
android:summary="@string/account_settings_incoming_summary" />
</PreferenceCategory>
@ -150,8 +158,8 @@
android:key="account_setup_auto_expand_folder"
android:singleLine="true"
android:title="@string/account_setup_auto_expand_folder"
android:summary=""
/>
android:summary="" />
<ListPreference
android:key="folder_display_mode"
android:title="@string/account_settings_folder_display_mode_label"
@ -181,22 +189,17 @@
<PreferenceScreen
android:key="composition"
android:summary="@string/account_settings_composition_summary"
android:title="@string/account_settings_composition_label"
/>
android:title="@string/account_settings_composition_label" />
<PreferenceScreen
android:key="manage_identities"
android:title="@string/account_settings_identities_label"
android:summary="@string/account_settings_identities_summary"
/>
android:summary="@string/account_settings_identities_summary" />
<PreferenceScreen
android:key="outgoing"
android:title="@string/account_settings_outgoing_label"
android:summary="@string/account_settings_outgoing_summary"
/>
android:summary="@string/account_settings_outgoing_summary" />
<EditTextPreference
android:key="account_quote_prefix"
@ -221,6 +224,7 @@
android:title="@string/account_settings_crypto_auto_signature"
android:summary="@string/account_settings_crypto_auto_signature_summary"
android:dependency="crypto_app"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/account_settings_notifications">
@ -253,6 +257,7 @@
android:defaultValue="false"
android:title="@string/account_settings_vibrate_enable"
android:summary="@string/account_settings_vibrate_summary" />
<ListPreference
android:dependency="account_vibrate"
android:key="account_vibrate_pattern"
@ -260,6 +265,7 @@
android:entries="@array/account_settings_vibrate_pattern_entries"
android:entryValues="@array/account_settings_vibrate_pattern_values"
android:dialogTitle="@string/account_settings_vibrate_pattern_label" />
<EditTextPreference
android:dependency="account_vibrate"
android:key="account_vibrate_times"
@ -269,12 +275,13 @@
android:summary=""
android:dialogTitle="@string/account_settings_vibrate_times" />
<CheckBoxPreference
<CheckBoxPreference
android:key="account_notify_sync"
android:title="@string/account_settings_notify_sync_label"
android:defaultValue="true"
android:summary="@string/account_settings_notify_sync_summary" />
<CheckBoxPreference
<CheckBoxPreference
android:key="notification_opens_unread"
android:title="@string/account_settings_notification_opens_unread_label"
android:defaultValue="true"

View File

@ -92,6 +92,7 @@ public class Account implements BaseAccount
private boolean mNotifySync;
private HideButtons mHideMessageViewButtons;
private HideButtons mHideMessageViewMoveButtons;
private ShowPictures mShowPictures;
private boolean mEnableMoveButtons;
private boolean mIsSignatureBeforeQuotedText;
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
@ -131,6 +132,11 @@ public class Account implements BaseAccount
NEVER, ALWAYS, KEYBOARD_AVAILABLE;
}
public enum ShowPictures
{
NEVER, ALWAYS, ONLY_FROM_CONTACTS;
}
public enum Searchable
{
ALL, DISPLAYABLE, NONE
@ -160,6 +166,7 @@ public class Account implements BaseAccount
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
mHideMessageViewButtons = HideButtons.NEVER;
mHideMessageViewMoveButtons = HideButtons.NEVER;
mShowPictures = ShowPictures.NEVER;
mEnableMoveButtons = false;
mRingtoneUri = "content://settings/system/notification_sound";
mIsSignatureBeforeQuotedText = false;
@ -303,6 +310,16 @@ public class Account implements BaseAccount
mHideMessageViewMoveButtons = HideButtons.NEVER;
}
try
{
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
ShowPictures.NEVER.name()));
}
catch (Exception e)
{
mShowPictures = ShowPictures.NEVER;
}
mEnableMoveButtons = prefs.getBoolean(mUuid + ".enableMoveButtons", false);
mRingtoneUri = prefs.getString(mUuid + ".ringtone",
@ -506,6 +523,7 @@ public class Account implements BaseAccount
editor.putBoolean(mUuid + ".ring", mRing);
editor.putString(mUuid + ".hideButtonsEnum", mHideMessageViewButtons.name());
editor.putString(mUuid + ".hideMoveButtonsEnum", mHideMessageViewMoveButtons.name());
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
editor.putString(mUuid + ".ringtone", mRingtoneUri);
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
@ -1008,6 +1026,16 @@ public class Account implements BaseAccount
mHideMessageViewMoveButtons = hideMessageViewButtons;
}
public synchronized ShowPictures getShowPictures()
{
return mShowPictures;
}
public synchronized void setShowPictures(ShowPictures showPictures)
{
mShowPictures = showPictures;
}
public synchronized FolderMode getFolderTargetMode()
{
return mFolderTargetMode;

View File

@ -55,6 +55,9 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.database.Cursor;
import com.fsck.k9.Account;
import com.fsck.k9.FontSizes;
@ -1669,12 +1672,19 @@ public class MessageView extends K9Activity implements OnClickListener
setLoadPictures(true);
}
/**
* Enable/disable image loading of the WebView. But always hide the
* "Show pictures" button!
*
* @param enable true, if (network) images should be loaded.
* false, otherwise.
*/
private void setLoadPictures(boolean enable)
{
K9.setBlockNetworkLoads(mMessageContentView.getSettings(), !enable);
mMessageContentView.getSettings().setBlockNetworkImage(!enable);
mShowPictures = enable;
mHandler.showShowPictures(!enable);
mHandler.showShowPictures(false);
}
public void onClick(View view)
@ -2148,9 +2158,42 @@ public class MessageView extends K9Activity implements OnClickListener
updateDecryptLayout();
}
});
if (mShowPictures == false)
// TODO: Only check for external (non inline) images
final boolean hasPictures = text.contains("<img");
// If the message contains pictures and the "Show pictures"
// button wasn't already pressed...
if (hasPictures && (mShowPictures == false))
{
mHandler.showShowPictures(text.contains("<img"));
boolean forceShowPictures = false;
if (account.getShowPictures() == Account.ShowPictures.ALWAYS)
{
forceShowPictures = true;
}
else if (account.getShowPictures() == Account.ShowPictures.ONLY_FROM_CONTACTS)
{
// TODO: change to _COUNT for speed
Cursor c = getContentResolver().query(Data.CONTENT_URI, new String[]{Data._ID},
Data.MIMETYPE + "='" + Email.CONTENT_ITEM_TYPE + "' AND "
+ Data.DATA1 + "=? AND "
+ Data.IN_VISIBLE_GROUP + "='1'",
new String[] { message.getFrom()[0].getAddress() }, null);
if ((c != null) && (c.getCount() > 0))
{
forceShowPictures = true;
}
}
if (forceShowPictures)
{
onShowPictures();
}
else
{
mHandler.showShowPictures(true);
}
}
}
else

View File

@ -44,6 +44,7 @@ public class AccountSettings extends K9PreferenceActivity
private static final String PREFERENCE_DEFAULT = "account_default";
private static final String PREFERENCE_HIDE_BUTTONS = "hide_buttons_enum";
private static final String PREFERENCE_HIDE_MOVE_BUTTONS = "hide_move_buttons_enum";
private static final String PREFERENCE_SHOW_PICTURES = "show_pictures_enum";
private static final String PREFERENCE_ENABLE_MOVE_BUTTONS = "enable_move_buttons";
private static final String PREFERENCE_NOTIFY = "account_notify";
private static final String PREFERENCE_NOTIFY_SELF = "account_notify_self";
@ -84,6 +85,7 @@ public class AccountSettings extends K9PreferenceActivity
private CheckBoxPreference mAccountNotifySelf;
private ListPreference mAccountHideButtons;
private ListPreference mAccountHideMoveButtons;
private ListPreference mAccountShowPictures;
private CheckBoxPreference mAccountEnableMoveButtons;
private CheckBoxPreference mAccountNotifySync;
private CheckBoxPreference mAccountVibrate;
@ -124,10 +126,9 @@ public class AccountSettings extends K9PreferenceActivity
boolean isPushCapable = false;
boolean isExpungeCapable = false;
Store store = null;
try
{
store = mAccount.getRemoteStore();
final Store store = mAccount.getRemoteStore();
isPushCapable = store.isPushCapable();
isExpungeCapable = store.isExpungeCapable();
}
@ -383,6 +384,21 @@ public class AccountSettings extends K9PreferenceActivity
}
});
mAccountShowPictures = (ListPreference) findPreference(PREFERENCE_SHOW_PICTURES);
mAccountShowPictures.setValue("" + mAccount.getShowPictures());
mAccountShowPictures.setSummary(mAccountShowPictures.getEntry());
mAccountShowPictures.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
public boolean onPreferenceChange(Preference preference, Object newValue)
{
final String summary = newValue.toString();
int index = mAccountShowPictures.findIndexOfValue(summary);
mAccountShowPictures.setSummary(mAccountShowPictures.getEntries()[index]);
mAccountShowPictures.setValue(summary);
return false;
}
});
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
mAccountNotify.setChecked(mAccount.isNotifyNewMail());
@ -633,6 +649,7 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setHideMessageViewButtons(Account.HideButtons.valueOf(mAccountHideButtons.getValue()));
mAccount.setHideMessageViewMoveButtons(Account.HideButtons.valueOf(mAccountHideMoveButtons.getValue()));
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
mAccount.setEnableMoveButtons(mAccountEnableMoveButtons.isChecked());
mAccount.setAutoExpandFolderName(reverseTranslateFolder(mAutoExpandFolder.getSummary().toString()));
mAccount.save(Preferences.getPreferences(this));