1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 12:05:06 -05:00

Merge branch 'master' into 3.2-MAINT

* master:
  Improved accessibility for next/prev buttons     (reported by a screenreader user)
  We've been seeing a lot of FCs on htmlifcation of large messages due to running out of memory during our heavy HTMLification. Try to be a bit lighter on the poor RAM if a plain text message is big.
This commit is contained in:
Jesse Vincent 2010-10-23 17:35:31 +00:00
parent 472b2d9d7a
commit aa494796b4
4 changed files with 22 additions and 0 deletions

View File

@ -62,6 +62,7 @@
<Button <Button
android:id="@+id/previous_scrolling" android:id="@+id/previous_scrolling"
android:text="@string/message_view_prev_action" android:text="@string/message_view_prev_action"
android:contentDescription="@string/previous_action"
android:textSize="35dip" android:textSize="35dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_width="0dip"
@ -88,6 +89,7 @@
<Button <Button
android:id="@+id/next_scrolling" android:id="@+id/next_scrolling"
android:text="@string/message_view_next_action" android:text="@string/message_view_next_action"
android:contentDescription="@string/next_action"
android:textSize="35dip" android:textSize="35dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="0dip" android:layout_width="0dip"
@ -136,6 +138,7 @@
<Button <Button
android:id="@+id/previous" android:id="@+id/previous"
android:text="@string/message_view_prev_action" android:text="@string/message_view_prev_action"
android:contentDescription="@string/previous_action"
android:textSize="35dip" android:textSize="35dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
@ -162,6 +165,7 @@
<Button <Button
android:id="@+id/next" android:id="@+id/next"
android:text="@string/message_view_next_action" android:text="@string/message_view_next_action"
android:contentDescription="@string/next_action"
android:textSize="35dip" android:textSize="35dip"
android:padding="0dip" android:padding="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -86,6 +86,7 @@
<Button <Button
android:id="@+id/previous_scrolling" android:id="@+id/previous_scrolling"
android:text="@string/message_view_prev_action" android:text="@string/message_view_prev_action"
android:contentDescription="@string/previous_action"
android:textSize="35dip" android:textSize="35dip"
android:padding="0dip" android:padding="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -149,6 +150,7 @@
<Button <Button
android:id="@+id/previous" android:id="@+id/previous"
android:text="@string/message_view_prev_action" android:text="@string/message_view_prev_action"
android:contentDescription="@string/previous_action"
android:textSize="35dip" android:textSize="35dip"
android:padding="0dip" android:padding="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -165,6 +167,7 @@
<Button <Button
android:id="@+id/next" android:id="@+id/next"
android:text="@string/message_view_next_action" android:text="@string/message_view_next_action"
android:contentDescription="@string/next_action"
android:textSize="35dip" android:textSize="35dip"
android:padding="0dip" android:padding="0dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -42,6 +42,7 @@
<!-- Actions will be used as buttons and in menu items --> <!-- Actions will be used as buttons and in menu items -->
<string name="next_action">Next</string> <!-- Used as part of a multi-step process --> <string name="next_action">Next</string> <!-- Used as part of a multi-step process -->
<string name="previous_action">Previous</string> <!-- Used as part of a multi-step process -->
<string name="okay_action">OK</string> <!-- User to confirm acceptance of dialog boxes, warnings, errors, etc. --> <string name="okay_action">OK</string> <!-- User to confirm acceptance of dialog boxes, warnings, errors, etc. -->
<string name="cancel_action">Cancel</string> <string name="cancel_action">Cancel</string>
<string name="send_action">Send</string> <string name="send_action">Send</string>

View File

@ -48,6 +48,8 @@ public class LocalStore extends Store implements Serializable
private static final int DB_VERSION = 39; private static final int DB_VERSION = 39;
private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED }; private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED };
private static final int MAX_SMART_HTMLIFY_MESSAGE_LENGTH = 1024 * 256 ;
private String mPath; private String mPath;
private SQLiteDatabase mDb; private SQLiteDatabase mDb;
private File mAttachmentsDir; private File mAttachmentsDir;
@ -2433,6 +2435,18 @@ public class LocalStore extends Store implements Serializable
public String htmlifyString(String text) public String htmlifyString(String text)
{ {
// Our HTMLification code is somewhat memory intensive
// and was causing lots of OOM errors on the market
// if the message is big and plain text, just do
// a trivial htmlification
if (text.length() > MAX_SMART_HTMLIFY_MESSAGE_LENGTH)
{
return "<html><head/><body>" +
htmlifyMessageHeader() +
text +
htmlifyMessageFooter() +
"</body></html>";
}
StringReader reader = new StringReader(text); StringReader reader = new StringReader(text);
StringBuilder buff = new StringBuilder(text.length() + 512); StringBuilder buff = new StringBuilder(text.length() + 512);
int c = 0; int c = 0;