mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Use HTML to format welcome message / make URL clickable
This commit is contained in:
parent
75329c45b3
commit
caa26311f1
@ -16,10 +16,10 @@
|
|||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/welcome_message"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="8dip"
|
android:padding="8dip"
|
||||||
android:text="@string/accounts_welcome"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
@ -22,32 +22,37 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Welcome message -->
|
<!-- Welcome message -->
|
||||||
<string name="welcome_message_title">Welcome to K-9 Mail!</string>
|
<string name="welcome_message_title">Welcome to K-9 Mail</string>
|
||||||
<string name="accounts_welcome">
|
<string name="accounts_welcome"><![CDATA[
|
||||||
Welcome to K-9 Mail! K-9 is a powerful free email client for Android.
|
<p>
|
||||||
\n\n
|
K-9 Mail is a powerful free email client for Android.
|
||||||
\nK-9\'s improved features include:
|
</p><p>
|
||||||
\n * Push mail using IMAP IDLE
|
Its improved features include:
|
||||||
\n * Better performance
|
</p>
|
||||||
\n * Message refiling
|
<ul>
|
||||||
\n * Email signatures
|
<li>Push mail using IMAP IDLE</li>
|
||||||
\n * Bcc-to-self
|
<li>Better performance</li>
|
||||||
\n * Folder subscriptions
|
<li>Message refiling</li>
|
||||||
\n * All folder synchronization
|
<li>Email signatures</li>
|
||||||
\n * Return-address configuration
|
<li>Bcc-to-self</li>
|
||||||
\n * Keyboard shortcuts
|
<li>Folder subscriptions</li>
|
||||||
\n * Better IMAP support
|
<li>All folder synchronization</li>
|
||||||
\n * Saving attachments to SD
|
<li>Return-address configuration</li>
|
||||||
\n * Empty Trash
|
<li>Keyboard shortcuts</li>
|
||||||
\n * Message sorting
|
<li>Better IMAP support</li>
|
||||||
\n * …and more
|
<li>Saving attachments to SD</li>
|
||||||
\n
|
<li>Empty Trash</li>
|
||||||
\nPlease note that K-9 does not support most free Hotmail accounts and, like many mail clients, has
|
<li>Message sorting</li>
|
||||||
|
<li>…and more</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
Please note that K-9 does not support most free Hotmail accounts and, like many mail clients, has
|
||||||
some quirks when talking to Microsoft Exchange.
|
some quirks when talking to Microsoft Exchange.
|
||||||
\n
|
</p><p>
|
||||||
\nPlease submit bug reports, contribute new features and ask questions at
|
Please submit bug reports, contribute new features and ask questions at
|
||||||
http://k9mail.googlecode.com/
|
<a href="http://k9mail.googlecode.com/">http://k9mail.googlecode.com/</a>.
|
||||||
</string>
|
</p>
|
||||||
|
]]></string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Default signature -->
|
<!-- Default signature -->
|
||||||
|
@ -3,12 +3,15 @@ package com.fsck.k9.activity.setup;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
|
import com.fsck.k9.helper.HtmlConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a welcome message when no accounts have been created yet.
|
* Displays a welcome message when no accounts have been created yet.
|
||||||
@ -24,6 +27,11 @@ public class WelcomeMessage extends K9Activity implements OnClickListener{
|
|||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
setContentView(R.layout.welcome_message);
|
setContentView(R.layout.welcome_message);
|
||||||
|
|
||||||
|
TextView welcome = (TextView) findViewById(R.id.welcome_message);
|
||||||
|
welcome.setText(HtmlConverter.htmlToSpanned(getString(R.string.accounts_welcome)));
|
||||||
|
welcome.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
((Button) findViewById(R.id.next)).setOnClickListener(this);
|
((Button) findViewById(R.id.next)).setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fsck.k9.helper;
|
package com.fsck.k9.helper;
|
||||||
|
|
||||||
import android.text.*;
|
import android.text.*;
|
||||||
|
import android.text.Html.TagHandler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
@ -1272,4 +1273,48 @@ public class HtmlConverter {
|
|||||||
// standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here.
|
// standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here.
|
||||||
return linkified.toString().replace("\n", "<br>\n").replace("'", "'");
|
return linkified.toString().replace("\n", "<br>\n").replace("'", "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert HTML to a {@link Spanned} that can be used in a {@link android.widget.TextView}.
|
||||||
|
*
|
||||||
|
* @param html
|
||||||
|
* The HTML fragment to be converted.
|
||||||
|
*
|
||||||
|
* @return A {@link Spanned} containing the text in {@code html} formatted using spans.
|
||||||
|
*/
|
||||||
|
public static Spanned htmlToSpanned(String html) {
|
||||||
|
return Html.fromHtml(html, null, new ListTagHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link TagHandler} that supports unordered lists.
|
||||||
|
*
|
||||||
|
* @see HtmlConverter#htmlToSpanned(String)
|
||||||
|
*/
|
||||||
|
public static class ListTagHandler implements TagHandler {
|
||||||
|
@Override
|
||||||
|
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
|
||||||
|
if (tag.equals("ul")) {
|
||||||
|
if (opening) {
|
||||||
|
char lastChar = 0;
|
||||||
|
if (output.length() > 0) {
|
||||||
|
lastChar = output.charAt(output.length() - 1);
|
||||||
|
}
|
||||||
|
if (lastChar != '\n') {
|
||||||
|
output.append("\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
output.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.equals("li")) {
|
||||||
|
if (opening) {
|
||||||
|
output.append("\t• ");
|
||||||
|
} else {
|
||||||
|
output.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user