Skip to content
Snippets Groups Projects
Commit bdde79b2 authored by akwizgran's avatar akwizgran
Browse files

Made the message body scrollable.

parent cabc13a7
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ import android.view.View.OnClickListener; ...@@ -30,6 +30,7 @@ import android.view.View.OnClickListener;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams; import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import com.google.inject.Inject; import com.google.inject.Inject;
...@@ -49,6 +50,7 @@ implements OnClickListener { ...@@ -49,6 +50,7 @@ implements OnClickListener {
private MessageId messageId = null; private MessageId messageId = null;
private boolean starred = false; private boolean starred = false;
private ImageButton starButton = null, replyButton = null; private ImageButton starButton = null, replyButton = null;
private TextView content = null;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
...@@ -104,10 +106,12 @@ implements OnClickListener { ...@@ -104,10 +106,12 @@ implements OnClickListener {
if(contentType.equals("text/plain")) { if(contentType.equals("text/plain")) {
// Load and display the message body // Load and display the message body
TextView content = new TextView(this); ScrollView scrollView = new ScrollView(this);
content = new TextView(this);
content.setPadding(10, 10, 10, 10); content.setPadding(10, 10, 10, 10);
layout.addView(content); scrollView.addView(content);
loadMessageBody(messageId, content); layout.addView(scrollView);
loadMessageBody();
} }
setContentView(layout); setContentView(layout);
...@@ -117,19 +121,21 @@ implements OnClickListener { ...@@ -117,19 +121,21 @@ implements OnClickListener {
serviceConnection, 0); serviceConnection, 0);
} }
private void loadMessageBody(final MessageId id, final TextView view) { private void loadMessageBody() {
final MessageId messageId = this.messageId;
final TextView content = this.content;
dbExecutor.execute(new Runnable() { dbExecutor.execute(new Runnable() {
public void run() { public void run() {
try { try {
// Wait for the service to be bound and started // Wait for the service to be bound and started
serviceConnection.waitForStartup(); serviceConnection.waitForStartup();
// Load the message body from the database // Load the message body from the database
byte[] body = db.getMessageBody(id); byte[] body = db.getMessageBody(messageId);
final String text = new String(body, "UTF-8"); final String text = new String(body, "UTF-8");
// Display the message body // Display the message body
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
view.setText(text); content.setText(text);
} }
}); });
} catch(DbException e) { } catch(DbException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment