diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java b/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java index 842cc75..fae5692 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java +++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailActivity.java @@ -2,8 +2,10 @@ package ch.dissem.apps.abit; import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; import android.support.v4.app.NavUtils; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.MenuItem; @@ -16,13 +18,15 @@ import android.view.MenuItem; * This activity is mostly just a 'shell' activity containing nothing * more than a {@link MessageDetailFragment}. */ -public class MessageDetailActivity extends ActionBarActivity { +public class MessageDetailActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_message_detail); + setContentView(R.layout.toolbar_layout); + final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); // Show the Up button in the action bar. getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -39,12 +43,12 @@ public class MessageDetailActivity extends ActionBarActivity { // Create the detail fragment and add it to the activity // using a fragment transaction. Bundle arguments = new Bundle(); - arguments.putString(MessageDetailFragment.ARG_ITEM, - getIntent().getStringExtra(MessageDetailFragment.ARG_ITEM)); + arguments.putSerializable(MessageDetailFragment.ARG_ITEM, + getIntent().getSerializableExtra(MessageDetailFragment.ARG_ITEM)); MessageDetailFragment fragment = new MessageDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() - .add(R.id.message_detail_container, fragment) + .add(R.id.content, fragment) .commit(); } } diff --git a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java index 8b430aa..03b3c30 100644 --- a/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/MessageDetailFragment.java @@ -5,8 +5,14 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; +import ch.dissem.apps.abit.service.Singleton; +import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.Plaintext; +import ch.dissem.bitmessage.entity.valueobject.Label; + +import java.util.Iterator; /** @@ -53,9 +59,29 @@ public class MessageDetailFragment extends Fragment { // Show the dummy content as text in a TextView. if (item != null) { - ((TextView) rootView.findViewById(R.id.message_detail)).setText(item.getText()); + ((TextView) rootView.findViewById(R.id.subject)).setText(item.getSubject()); + BitmessageAddress sender = item.getFrom(); + ((ImageView) rootView.findViewById(R.id.avatar)).setImageDrawable(new Identicon(sender)); + ((TextView) rootView.findViewById(R.id.sender)).setText(sender.toString()); + if (item.getTo() != null) { + ((TextView) rootView.findViewById(R.id.recipient)).setText(item.getTo().toString()); + } else if (item.getType() == Plaintext.Type.BROADCAST) { + ((TextView) rootView.findViewById(R.id.recipient)).setText(R.string.broadcast); + } + ((TextView) rootView.findViewById(R.id.text)).setText(item.getText()); } + boolean removed = false; + Iterator