From e5b00c74535049eb4f695a603d79931b3e1dac9a Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 28 Aug 2015 13:49:53 +0200 Subject: [PATCH] Added proper message list, and almost nice notifications --- .../apps/abit/MessageDetailActivity.java | 16 +-- .../apps/abit/MessageDetailFragment.java | 28 +++++- .../dissem/apps/abit/MessageListActivity.java | 21 ++-- .../dissem/apps/abit/MessageListFragment.java | 30 +++++- .../ch/dissem/apps/abit/MessageListener.java | 69 +++++++++++++ .../AndroidAddressRepository.java | 8 +- .../abit/repositories/AndroidInventory.java | 8 +- .../AndroidMessageRepository.java | 11 ++- .../apps/abit/repositories/SqlHelper.java | 1 - .../dissem/apps/abit/service/Singleton.java | 15 ++- .../ic_notification_new_message.png | Bin 0 -> 356 bytes .../ic_notification_new_message.png | Bin 0 -> 273 bytes .../ic_notification_new_message.png | Bin 0 -> 455 bytes .../ic_notification_new_message.png | Bin 0 -> 660 bytes .../res/layout/activity_message_detail.xml | 25 ----- .../layout/activity_open_bitmessage_link.xml | 41 +++++--- .../res/layout/fragment_message_detail.xml | 91 ++++++++++++++++-- app/src/main/res/layout/message_row.xml | 80 +++++++++++++++ app/src/main/res/values-de/labels.xml | 2 +- app/src/main/res/values-de/strings.xml | 14 ++- app/src/main/res/values/labels.xml | 2 +- app/src/main/res/values/strings.xml | 4 +- app/src/main/res/values/styles.xml | 16 +-- build.gradle | 2 +- 24 files changed, 390 insertions(+), 94 deletions(-) create mode 100644 app/src/main/java/ch/dissem/apps/abit/MessageListener.java create mode 100644 app/src/main/res/drawable-hdpi/ic_notification_new_message.png create mode 100644 app/src/main/res/drawable-mdpi/ic_notification_new_message.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_notification_new_message.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_notification_new_message.png delete mode 100644 app/src/main/res/layout/activity_message_detail.xml create mode 100644 app/src/main/res/layout/message_row.xml 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