diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fae7ac1d9..f3e69ba12 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -246,6 +246,10 @@
+
+
+
+
+
diff --git a/res/layout/message_view_header.xml b/res/layout/message_view_header.xml
index f0dbd7561..c7878a913 100644
--- a/res/layout/message_view_header.xml
+++ b/res/layout/message_view_header.xml
@@ -251,6 +251,10 @@
android:id="@+id/message_content"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
+
screenReaders = getPackageManager().queryIntentServices(
+ screenReaderIntent, 0);
+ ContentResolver cr = getContentResolver();
+ Cursor cursor = null;
+ int status = 0;
+ for (ResolveInfo screenReader : screenReaders)
+ {
+ // All screen readers are expected to implement a content provider
+ // that responds to
+ // content://.providers.StatusProvider
+ cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName
+ + ".providers.StatusProvider"), null, null, null, null);
+ if (cursor != null)
+ {
+ cursor.moveToFirst();
+ // These content providers use a special cursor that only has
+ // one element,
+ // an integer that is 1 if the screen reader is running.
+ status = cursor.getInt(0);
+ cursor.close();
+ if (status == 1)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
@Override
protected void onSaveInstanceState(Bundle outState)
{
@@ -2127,9 +2201,18 @@ public class MessageView extends K9Activity implements OnClickListener
{
public void run()
{
- mMessageContentView.loadDataWithBaseURL("http://", emailText, mimeType, "utf-8", null);
mTopView.scrollTo(0, 0);
- mMessageContentView.scrollTo(0, 0);
+ if (mScreenReaderEnabled)
+ {
+ mAccessibleMessageContentView.loadDataWithBaseURL("http://",
+ emailText, "text/html", "utf-8", null);
+ }
+ else
+ {
+ mMessageContentView.loadDataWithBaseURL("http://", emailText,
+ "text/html", "utf-8", null);
+ mMessageContentView.scrollTo(0, 0);
+ }
updateDecryptLayout();
}
});
diff --git a/src/com/fsck/k9/web/AccessibleEmailContentActivity.java b/src/com/fsck/k9/web/AccessibleEmailContentActivity.java
new file mode 100644
index 000000000..f7dd51f89
--- /dev/null
+++ b/src/com/fsck/k9/web/AccessibleEmailContentActivity.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 The IDEAL Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.fsck.k9.web;
+
+import java.util.ArrayList;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.Spanned;
+import android.widget.ArrayAdapter;
+
+public class AccessibleEmailContentActivity extends ListActivity {
+ String[] listItems = {
+ ""
+ };
+
+ private String htmlSource;
+
+ private ArrayList cleanedList;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ htmlSource = getIntent().getStringExtra("content");
+ Spanned parsedHtml = Html.fromHtml(htmlSource, null, null);
+ String[] rawListItems = parsedHtml.toString().split("\n");
+
+ cleanedList = new ArrayList();
+ for (int i = 0; i < rawListItems.length; i++) {
+ if (rawListItems[i].trim().length() > 0) {
+ addToCleanedList(rawListItems[i]);
+ }
+ }
+
+ listItems = cleanedList.toArray(listItems);
+
+ setContentView(com.fsck.k9.R.layout.accessible_email_content);
+ setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, listItems));
+ }
+
+ private void addToCleanedList(String line) {
+ if (line.length() < 80) {
+ cleanedList.add(line);
+ } else {
+ while (line.length() > 80) {
+ int cutPoint = line.indexOf(" ", 80);
+ if ((cutPoint > 0) && (cutPoint < line.length())) {
+ cleanedList.add(line.substring(0, cutPoint));
+ line = line.substring(cutPoint).trim();
+ } else {
+ cleanedList.add(line);
+ line = "";
+ }
+ }
+ if (line.length() > 0) {
+ cleanedList.add(line);
+ }
+ }
+ }
+
+}
diff --git a/src/com/fsck/k9/web/AccessibleWebView.java b/src/com/fsck/k9/web/AccessibleWebView.java
new file mode 100644
index 000000000..4545d4383
--- /dev/null
+++ b/src/com/fsck/k9/web/AccessibleWebView.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2010 The IDEAL Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.fsck.k9.web;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.text.Html;
+import android.util.AttributeSet;
+import android.view.View;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.widget.TextView;
+
+public class AccessibleWebView extends TextView {
+ private Activity parent;
+
+ private String htmlSource;
+
+ private WebView dummyWebView;
+
+ public AccessibleWebView(Context context) {
+ super(context);
+ parent = (Activity) context;
+ dummyWebView = new WebView(context);
+ setFocusable(true);
+ setFocusableInTouchMode(true);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ diveIn();
+ }
+ });
+ }
+
+ public AccessibleWebView(Context context, AttributeSet attributes) {
+ super(context, attributes);
+ parent = (Activity) context;
+ dummyWebView = new WebView(context);
+ setFocusable(true);
+ setFocusableInTouchMode(true);
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ diveIn();
+ }
+ });
+
+ }
+
+ public void loadData(String data, String mimeType, String encoding) {
+ htmlSource = data;
+ this.setText(Html.fromHtml(htmlSource, null, null));
+ }
+
+ public WebSettings getSettings() {
+ return dummyWebView.getSettings();
+ }
+
+ public void setVerticalScrollbarOverlay(boolean booleanValue) {
+ // Do nothing here; dummy stub method to maintain compatibility with
+ // standard WebView.
+ }
+
+ public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding,
+ String historyUrl) {
+ htmlSource = data;
+ this.setText(Html.fromHtml(htmlSource, null, null));
+ }
+
+ public void loadUrl(String url) {
+ // Do nothing here; dummy stub method to maintain compatibility with
+ // standard WebView.
+ }
+
+ public boolean zoomIn() {
+ if (getTextSize() < 100) {
+ setTextSize(getTextSize() + 5);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean zoomOut() {
+ if (getTextSize() > 5) {
+ setTextSize(getTextSize() - 5);
+ return true;
+ }
+ return false;
+ }
+
+ private void diveIn() {
+ Intent i = new Intent();
+ i.setClass(parent, AccessibleEmailContentActivity.class);
+ i.putExtra("content", htmlSource);
+ parent.startActivity(i);
+ }
+}
diff --git a/tools/build-beta b/tools/build-beta
old mode 100755
new mode 100644