diff --git a/app/src/main/assets/db/migration/V3.4__Add_label_outbox.sql b/app/src/main/assets/db/migration/V3.4__Add_label_outbox.sql new file mode 100644 index 0000000..d61bcc9 --- /dev/null +++ b/app/src/main/assets/db/migration/V3.4__Add_label_outbox.sql @@ -0,0 +1 @@ +INSERT INTO Label(label, type, ord) VALUES ('Outbox', 'OUTBOX', 15); diff --git a/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.java b/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.java index eff915a..5af7c3d 100644 --- a/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentActivity; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; @@ -101,10 +102,11 @@ public class AddressDetailFragment extends Fragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.address, menu); - Drawables.addIcon(getActivity(), menu, R.id.write_message, GoogleMaterial.Icon.gmd_mail); - Drawables.addIcon(getActivity(), menu, R.id.share, GoogleMaterial.Icon.gmd_share); - Drawables.addIcon(getActivity(), menu, R.id.delete, GoogleMaterial.Icon.gmd_delete); - Drawables.addIcon(getActivity(), menu, R.id.export, + FragmentActivity activity = getActivity(); + Drawables.addIcon(activity, menu, R.id.write_message, GoogleMaterial.Icon.gmd_mail); + Drawables.addIcon(activity, menu, R.id.share, GoogleMaterial.Icon.gmd_share); + Drawables.addIcon(activity, menu, R.id.delete, GoogleMaterial.Icon.gmd_delete); + Drawables.addIcon(activity, menu, R.id.export, CommunityMaterial.Icon.cmd_export) .setVisible(item != null && item.getPrivateKey() != null); @@ -185,6 +187,17 @@ public class AddressDetailFragment extends Fragment { // Show the dummy content as text in a TextView. if (item != null) { + FragmentActivity activity = getActivity(); + if (item.isChan()) { + activity.setTitle(R.string.title_chan_detail); + } else if (item.getPrivateKey() != null) { + activity.setTitle(R.string.title_identity_detail); + } else if (item.isSubscribed()) { + activity.setTitle(R.string.title_subscription_detail); + } else { + activity.setTitle(R.string.title_contact_detail); + } + ((ImageView) rootView.findViewById(R.id.avatar)).setImageDrawable(new Identicon(item)); TextView name = (TextView) rootView.findViewById(R.id.name); name.setText(item.toString()); @@ -207,8 +220,8 @@ public class AddressDetailFragment extends Fragment { TextView address = (TextView) rootView.findViewById(R.id.address); address.setText(item.getAddress()); address.setSelected(true); - ((TextView) rootView.findViewById(R.id.stream_number)).setText(getActivity() - .getString(R.string.stream_number, item.getStream())); + ((TextView) rootView.findViewById(R.id.stream_number)).setText( + getString(R.string.stream_number, item.getStream())); if (item.getPrivateKey() == null) { Switch active = (Switch) rootView.findViewById(R.id.active); active.setChecked(item.isSubscribed()); diff --git a/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java b/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java index 57aa3dd..df6785c 100644 --- a/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/AddressListFragment.java @@ -93,13 +93,14 @@ public class AddressListFragment extends AbstractItemListFragment unacknowledged = new LinkedList<>(); private int numberOfUnacknowledgedMessages = 0; private final NewMessageNotification notification; + private final ExecutorService pool = Executors.newSingleThreadExecutor(); public MessageListener(Context ctx) { this.notification = new NewMessageNotification(ctx); @@ -45,33 +48,32 @@ public class MessageListener implements BitmessageContext.Listener { @Override public void receive(final Plaintext plaintext) { - synchronized (unacknowledged) { + pool.submit(() -> { unacknowledged.addFirst(plaintext); numberOfUnacknowledgedMessages++; if (unacknowledged.size() > 5) { unacknowledged.removeLast(); } - } + if (numberOfUnacknowledgedMessages == 1) { + notification.singleNotification(plaintext); + } else { + notification.multiNotification(unacknowledged, numberOfUnacknowledgedMessages); + } + notification.show(); - if (numberOfUnacknowledgedMessages == 1) { - notification.singleNotification(plaintext); - } else { - notification.multiNotification(unacknowledged, numberOfUnacknowledgedMessages); - } - notification.show(); - - // If MainActivity is shown, update the sidebar badges - MainActivity main = MainActivity.getInstance(); - if (main != null) { - main.updateUnread(); - } + // If MainActivity is shown, update the sidebar badges + MainActivity main = MainActivity.getInstance(); + if (main != null) { + main.updateUnread(); + } + }); } public void resetNotification() { - notification.hide(); - synchronized (unacknowledged) { + pool.submit(() -> { + notification.hide(); unacknowledged.clear(); numberOfUnacknowledgedMessages = 0; - } + }); } } diff --git a/app/src/main/java/ch/dissem/apps/abit/repository/AndroidMessageRepository.java b/app/src/main/java/ch/dissem/apps/abit/repository/AndroidMessageRepository.java index 03420bd..228c67e 100644 --- a/app/src/main/java/ch/dissem/apps/abit/repository/AndroidMessageRepository.java +++ b/app/src/main/java/ch/dissem/apps/abit/repository/AndroidMessageRepository.java @@ -123,6 +123,9 @@ public class AndroidMessageRepository extends AbstractMessageRepository { case DRAFT: text = context.getString(R.string.draft); break; + case OUTBOX: + text = context.getString(R.string.outbox); + break; case SENT: text = context.getString(R.string.sent); break; @@ -197,7 +200,7 @@ public class AndroidMessageRepository extends AbstractMessageRepository { TABLE_NAME, projection, where, null, null, null, - COLUMN_RECEIVED + " DESC" + COLUMN_RECEIVED + " DESC, " + COLUMN_SENT + " DESC" )) { while (c.moveToNext()) { byte[] iv = c.getBlob(c.getColumnIndex(COLUMN_IV)); diff --git a/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java b/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java index 5e6a68c..0e95170 100644 --- a/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java +++ b/app/src/main/java/ch/dissem/apps/abit/repository/SqlHelper.java @@ -27,7 +27,7 @@ import ch.dissem.apps.abit.util.Assets; */ public class SqlHelper extends SQLiteOpenHelper { // If you change the database schema, you must increment the database version. - private static final int DATABASE_VERSION = 5; + private static final int DATABASE_VERSION = 6; private static final String DATABASE_NAME = "jabit.db"; private final Context ctx; @@ -59,6 +59,8 @@ public class SqlHelper extends SQLiteOpenHelper { executeMigration(db, "V3.2__Update_table_message"); case 4: executeMigration(db, "V3.3__Create_table_node"); + case 5: + executeMigration(db, "V3.4__Add_label_outbox"); default: // Nothing to do. Let's assume we won't upgrade from a version that's newer than // DATABASE_VERSION. diff --git a/app/src/main/java/ch/dissem/apps/abit/util/Assets.java b/app/src/main/java/ch/dissem/apps/abit/util/Assets.java index db9b54c..5d07f6f 100644 --- a/app/src/main/java/ch/dissem/apps/abit/util/Assets.java +++ b/app/src/main/java/ch/dissem/apps/abit/util/Assets.java @@ -17,6 +17,8 @@ package ch.dissem.apps.abit.util; import android.content.Context; +import android.support.annotation.DrawableRes; +import android.support.annotation.StringRes; import java.io.IOException; import java.io.InputStream; @@ -24,6 +26,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Scanner; +import ch.dissem.apps.abit.R; +import ch.dissem.bitmessage.entity.Plaintext; + /** * Helper class to work with Assets. */ @@ -44,4 +49,44 @@ public class Assets { throw new RuntimeException(e); } } + + @DrawableRes + public static int getStatusDrawable(Plaintext.Status status) { + switch (status) { + case RECEIVED: + return 0; + case DRAFT: + return R.drawable.draft; + case PUBKEY_REQUESTED: + return R.drawable.public_key; + case DOING_PROOF_OF_WORK: + return R.drawable.ic_notification_proof_of_work; + case SENT: + return R.drawable.sent; + case SENT_ACKNOWLEDGED: + return R.drawable.sent_acknowledged; + default: + return 0; + } + } + + @StringRes + public static int getStatusString(Plaintext.Status status) { + switch (status) { + case RECEIVED: + return R.string.status_received; + case DRAFT: + return R.string.status_draft; + case PUBKEY_REQUESTED: + return R.string.status_public_key; + case DOING_PROOF_OF_WORK: + return R.string.proof_of_work_title; + case SENT: + return R.string.status_sent; + case SENT_ACKNOWLEDGED: + return R.string.status_sent_acknowledged; + default: + return 0; + } + } } diff --git a/app/src/main/res/drawable/draft.xml b/app/src/main/res/drawable/draft.xml new file mode 100644 index 0000000..64dd791 --- /dev/null +++ b/app/src/main/res/drawable/draft.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/drawable/sent.xml b/app/src/main/res/drawable/sent.xml new file mode 100644 index 0000000..0f4e328 --- /dev/null +++ b/app/src/main/res/drawable/sent.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/drawable/sent_acknowledged.xml b/app/src/main/res/drawable/sent_acknowledged.xml new file mode 100644 index 0000000..1970559 --- /dev/null +++ b/app/src/main/res/drawable/sent_acknowledged.xml @@ -0,0 +1,25 @@ + + + + + diff --git a/app/src/main/res/layout/fragment_message_detail.xml b/app/src/main/res/layout/fragment_message_detail.xml index 053a8d4..b0a7ef5 100644 --- a/app/src/main/res/layout/fragment_message_detail.xml +++ b/app/src/main/res/layout/fragment_message_detail.xml @@ -2,34 +2,47 @@ + android:layout_height="match_parent"> + tools:ignore="UnusedAttribute" + tools:text="Subject"/> + + + android:background="@color/divider"/> + android:textStyle="bold" + tools:text="Sender"/> + tools:text="Recipient"/> + android:textIsSelectable="true"/> - \ No newline at end of file + diff --git a/app/src/main/res/layout/message_row.xml b/app/src/main/res/layout/message_row.xml index 486df04..f23d5c1 100644 --- a/app/src/main/res/layout/message_row.xml +++ b/app/src/main/res/layout/message_row.xml @@ -44,7 +44,7 @@ android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_margin="16dp" - android:src="@color/colorAccent" + android:src="@color/colorPrimaryDark" tools:ignore="ContentDescription"/> + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 3a5b347..ec78307 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -101,4 +101,13 @@ Als Alternative kann in den Einstellungen ein vertrauenswürdiger Knoten konfigu Knoten starten Nachricht Bitte versuchs nochmals wenn eine Identität verfügbar ist. + Chan + Kontakt + Identität + Postausgang + Entwurf + öffentlicher Schlüssel angefordert + empfangen + gesendet + Empfang bestätigt diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 68f92a0..262b398 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,8 +1,11 @@ Abit A Bitmessage client for Android - Message Detail - Subscription Detail + Message + Subscription + Chan + Identity + Contact Bitmessage Node Settings Wi-Fi only @@ -100,4 +103,10 @@ As an alternative you could configure a trusted node in the settings, but as of Startup node Message Please try again once an identity is available. + public key requested + acknowledged + draft + sent + received + Outbox