Merge branch 'develop' into feature/conversations
This commit is contained in:
commit
22ac1920a2
@ -18,6 +18,7 @@ package ch.dissem.apps.abit;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
@ -53,13 +54,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.dialog.AddIdentityDialogFragment;
|
import ch.dissem.apps.abit.dialog.AddIdentityDialogFragment;
|
||||||
import ch.dissem.apps.abit.dialog.FullNodeDialogActivity;
|
import ch.dissem.apps.abit.dialog.FullNodeDialogActivity;
|
||||||
import ch.dissem.apps.abit.listener.ActionBarListener;
|
import ch.dissem.apps.abit.listener.ActionBarListener;
|
||||||
import ch.dissem.apps.abit.listener.ListSelectionListener;
|
import ch.dissem.apps.abit.listener.ListSelectionListener;
|
||||||
|
import ch.dissem.apps.abit.repository.AndroidMessageRepository;
|
||||||
import ch.dissem.apps.abit.service.BitmessageService;
|
import ch.dissem.apps.abit.service.BitmessageService;
|
||||||
import ch.dissem.apps.abit.service.Singleton;
|
import ch.dissem.apps.abit.service.Singleton;
|
||||||
import ch.dissem.apps.abit.synchronization.SyncAdapter;
|
import ch.dissem.apps.abit.synchronization.SyncAdapter;
|
||||||
@ -125,12 +126,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
instance = new WeakReference<>(this);
|
instance = new WeakReference<>(this);
|
||||||
bmc = Singleton.getBitmessageContext(this);
|
bmc = Singleton.getBitmessageContext(this);
|
||||||
List<Label> labels = bmc.messages().getLabels();
|
|
||||||
if (getIntent().hasExtra(EXTRA_SHOW_LABEL)) {
|
|
||||||
selectedLabel = (Label) getIntent().getSerializableExtra(EXTRA_SHOW_LABEL);
|
|
||||||
} else if (selectedLabel == null) {
|
|
||||||
selectedLabel = labels.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_message_list);
|
setContentView(R.layout.activity_message_list);
|
||||||
|
|
||||||
@ -155,7 +150,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
listFragment.setActivateOnItemClick(true);
|
listFragment.setActivateOnItemClick(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
createDrawer(toolbar, labels);
|
createDrawer(toolbar);
|
||||||
|
|
||||||
// handle intents
|
// handle intents
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
@ -217,22 +212,8 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDrawer(Toolbar toolbar, Collection<Label> labels) {
|
private void createDrawer(Toolbar toolbar) {
|
||||||
final ArrayList<IProfile> profiles = new ArrayList<>();
|
final ArrayList<IProfile> profiles = new ArrayList<>();
|
||||||
for (BitmessageAddress identity : bmc.addresses().getIdentities()) {
|
|
||||||
LOG.info("Adding identity " + identity.getAddress());
|
|
||||||
profiles.add(new ProfileDrawerItem()
|
|
||||||
.withIcon(new Identicon(identity))
|
|
||||||
.withName(identity.toString())
|
|
||||||
.withNameShown(true)
|
|
||||||
.withEmail(identity.getAddress())
|
|
||||||
.withTag(identity)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (profiles.isEmpty()) {
|
|
||||||
// Create an initial identity
|
|
||||||
Singleton.getIdentity(this);
|
|
||||||
}
|
|
||||||
profiles.add(new ProfileSettingDrawerItem()
|
profiles.add(new ProfileSettingDrawerItem()
|
||||||
.withName(getString(R.string.add_identity))
|
.withName(getString(R.string.add_identity))
|
||||||
.withDescription(getString(R.string.add_identity_summary))
|
.withDescription(getString(R.string.add_identity_summary))
|
||||||
@ -288,46 +269,10 @@ public class MainActivity extends AppCompatActivity
|
|||||||
accountHeader.setActiveProfile(profiles.get(0), true);
|
accountHeader.setActiveProfile(profiles.get(0), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<IDrawerItem> drawerItems = new ArrayList<>();
|
final ArrayList<IDrawerItem> drawerItems = new ArrayList<>();
|
||||||
for (Label label : labels) {
|
|
||||||
PrimaryDrawerItem item = new PrimaryDrawerItem()
|
|
||||||
.withName(label.toString())
|
|
||||||
.withTag(label);
|
|
||||||
if (label.getType() == null) {
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_label)
|
|
||||||
.withIconColor(label.getColor());
|
|
||||||
} else {
|
|
||||||
switch (label.getType()) {
|
|
||||||
case INBOX:
|
|
||||||
item.withIcon(GoogleMaterial.Icon.gmd_inbox);
|
|
||||||
break;
|
|
||||||
case DRAFT:
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_file);
|
|
||||||
break;
|
|
||||||
case OUTBOX:
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_outbox);
|
|
||||||
break;
|
|
||||||
case SENT:
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_send);
|
|
||||||
break;
|
|
||||||
case BROADCAST:
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_rss);
|
|
||||||
break;
|
|
||||||
case UNREAD:
|
|
||||||
item.withIcon(GoogleMaterial.Icon.gmd_markunread_mailbox);
|
|
||||||
break;
|
|
||||||
case TRASH:
|
|
||||||
item.withIcon(GoogleMaterial.Icon.gmd_delete);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
item.withIcon(CommunityMaterial.Icon.cmd_label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drawerItems.add(item);
|
|
||||||
}
|
|
||||||
drawerItems.add(new PrimaryDrawerItem()
|
drawerItems.add(new PrimaryDrawerItem()
|
||||||
.withName(R.string.archive)
|
.withName(R.string.archive)
|
||||||
.withTag(null)
|
.withTag(AndroidMessageRepository.LABEL_ARCHIVE)
|
||||||
.withIcon(CommunityMaterial.Icon.cmd_archive)
|
.withIcon(CommunityMaterial.Icon.cmd_archive)
|
||||||
);
|
);
|
||||||
drawerItems.add(new DividerDrawerItem());
|
drawerItems.add(new DividerDrawerItem());
|
||||||
@ -384,10 +329,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
startActivity(new Intent(MainActivity.this, SettingsActivity
|
startActivity(new Intent(MainActivity.this, SettingsActivity
|
||||||
.class));
|
.class));
|
||||||
break;
|
break;
|
||||||
case R.string.archive:
|
|
||||||
selectedLabel = null;
|
|
||||||
showSelectedLabel();
|
|
||||||
break;
|
|
||||||
case R.string.full_node:
|
case R.string.full_node:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -397,6 +338,59 @@ public class MainActivity extends AppCompatActivity
|
|||||||
})
|
})
|
||||||
.withShowDrawerOnFirstLaunch(true)
|
.withShowDrawerOnFirstLaunch(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, List<BitmessageAddress>>() {
|
||||||
|
@Override
|
||||||
|
protected List<BitmessageAddress> doInBackground(Void... params) {
|
||||||
|
List<BitmessageAddress> identities = bmc.addresses().getIdentities();
|
||||||
|
if (identities.isEmpty()) {
|
||||||
|
// Create an initial identity
|
||||||
|
Singleton.getIdentity(MainActivity.this);
|
||||||
|
}
|
||||||
|
return identities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<BitmessageAddress> identities) {
|
||||||
|
for (BitmessageAddress identity : identities) {
|
||||||
|
addIdentityEntry(identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, List<Label>>() {
|
||||||
|
@Override
|
||||||
|
protected List<Label> doInBackground(Void... params) {
|
||||||
|
return bmc.messages().getLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<Label> labels) {
|
||||||
|
if (getIntent().hasExtra(EXTRA_SHOW_LABEL)) {
|
||||||
|
selectedLabel = (Label) getIntent().getSerializableExtra(EXTRA_SHOW_LABEL);
|
||||||
|
} else if (selectedLabel == null) {
|
||||||
|
selectedLabel = labels.get(0);
|
||||||
|
}
|
||||||
|
for (Label label : labels) {
|
||||||
|
addLabelEntry(label);
|
||||||
|
}
|
||||||
|
showSelectedLabel();
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
|
savedInstanceState.putSerializable("selectedLabel", selectedLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
|
selectedLabel = (Label) savedInstanceState.getSerializable("selectedLabel");
|
||||||
|
showSelectedLabel();
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIdentityDialog() {
|
private void addIdentityDialog() {
|
||||||
@ -429,6 +423,43 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addLabelEntry(Label label) {
|
||||||
|
PrimaryDrawerItem item = new PrimaryDrawerItem()
|
||||||
|
.withName(label.toString())
|
||||||
|
.withTag(label);
|
||||||
|
if (label.getType() == null) {
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_label)
|
||||||
|
.withIconColor(label.getColor());
|
||||||
|
} else {
|
||||||
|
switch (label.getType()) {
|
||||||
|
case INBOX:
|
||||||
|
item.withIcon(GoogleMaterial.Icon.gmd_inbox);
|
||||||
|
break;
|
||||||
|
case DRAFT:
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_file);
|
||||||
|
break;
|
||||||
|
case OUTBOX:
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_outbox);
|
||||||
|
break;
|
||||||
|
case SENT:
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_send);
|
||||||
|
break;
|
||||||
|
case BROADCAST:
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_rss);
|
||||||
|
break;
|
||||||
|
case UNREAD:
|
||||||
|
item.withIcon(GoogleMaterial.Icon.gmd_markunread_mailbox);
|
||||||
|
break;
|
||||||
|
case TRASH:
|
||||||
|
item.withIcon(GoogleMaterial.Icon.gmd_delete);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
item.withIcon(CommunityMaterial.Icon.cmd_label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawer.addItemAtPosition(item, drawer.getDrawerItems().size() - 3);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateIdentityEntry(BitmessageAddress identity) {
|
public void updateIdentityEntry(BitmessageAddress identity) {
|
||||||
for (IProfile profile : accountHeader.getProfiles()) {
|
for (IProfile profile : accountHeader.getProfiles()) {
|
||||||
if (profile instanceof ProfileDrawerItem) {
|
if (profile instanceof ProfileDrawerItem) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package ch.dissem.apps.abit;
|
package ch.dissem.apps.abit;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
@ -37,7 +38,9 @@ import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeMana
|
|||||||
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
|
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.adapter.SwipeableMessageAdapter;
|
import ch.dissem.apps.abit.adapter.SwipeableMessageAdapter;
|
||||||
import ch.dissem.apps.abit.listener.ActionBarListener;
|
import ch.dissem.apps.abit.listener.ActionBarListener;
|
||||||
@ -102,27 +105,54 @@ public class MessageListFragment extends Fragment implements ListHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateList(Label label) {
|
public void updateList(Label label) {
|
||||||
currentLabel = label;
|
if (!isResumed()) {
|
||||||
|
currentLabel = label;
|
||||||
if (!isVisible()) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Objects.equals(currentLabel, label)) {
|
||||||
|
adapter.setData(label, Collections.<Plaintext>emptyList());
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
doUpdateList(label);
|
doUpdateList(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUpdateList(Label label) {
|
private void doUpdateList(final Label label) {
|
||||||
List<Plaintext> messages = Singleton.getMessageRepository(getContext()).findMessages(label);
|
if (label == null) {
|
||||||
|
if (getActivity() instanceof ActionBarListener) {
|
||||||
|
((ActionBarListener) getActivity()).updateTitle(getString(R.string.app_name));
|
||||||
|
}
|
||||||
|
adapter.setData(null, Collections.<Plaintext>emptyList());
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentLabel = label;
|
||||||
|
if (emptyTrashMenuItem != null) {
|
||||||
|
emptyTrashMenuItem.setVisible(label.getType() == Label.Type.TRASH);
|
||||||
|
}
|
||||||
if (getActivity() instanceof ActionBarListener) {
|
if (getActivity() instanceof ActionBarListener) {
|
||||||
if (label != null) {
|
ActionBarListener actionBarListener = (ActionBarListener) getActivity();
|
||||||
((ActionBarListener) getActivity()).updateTitle(label.toString());
|
if ("archive".equals(label.toString())) {
|
||||||
|
actionBarListener.updateTitle(getString(R.string.archive));
|
||||||
} else {
|
} else {
|
||||||
((ActionBarListener) getActivity()).updateTitle(getString(R.string.archive));
|
actionBarListener.updateTitle(label.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (emptyTrashMenuItem != null) {
|
new AsyncTask<Void, Void, List<Plaintext>>() {
|
||||||
emptyTrashMenuItem.setVisible(label != null && label.getType() == Label.Type.TRASH);
|
|
||||||
}
|
@Override
|
||||||
adapter.setData(label, messages);
|
protected List<Plaintext> doInBackground(Void... params) {
|
||||||
adapter.notifyDataSetChanged();
|
return messageRepo.findMessages(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<Plaintext> messages) {
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter.setData(label, messages);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -276,11 +306,20 @@ public class MessageListFragment extends Fragment implements ListHolder {
|
|||||||
case R.id.empty_trash:
|
case R.id.empty_trash:
|
||||||
if (currentLabel.getType() != Label.Type.TRASH) return true;
|
if (currentLabel.getType() != Label.Type.TRASH) return true;
|
||||||
|
|
||||||
MessageRepository repo = Singleton.getMessageRepository(getContext());
|
new AsyncTask<Void, Void, Void>() {
|
||||||
for (Plaintext message : repo.findMessages(currentLabel)) {
|
@Override
|
||||||
repo.remove(message);
|
protected Void doInBackground(Void... params) {
|
||||||
}
|
for (Plaintext message : messageRepo.findMessages(currentLabel)) {
|
||||||
updateList(currentLabel);
|
messageRepo.remove(message);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
updateList(currentLabel);
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,23 +67,25 @@ public class SettingsFragment
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
private Context ctx = getActivity().getApplicationContext();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
cleanup.setEnabled(false);
|
cleanup.setEnabled(false);
|
||||||
Toast.makeText(getActivity(), R.string.cleanup_notification_start, Toast
|
Toast.makeText(ctx, R.string.cleanup_notification_start, Toast
|
||||||
.LENGTH_SHORT).show();
|
.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
Singleton.getBitmessageContext(getActivity()).cleanup();
|
Singleton.getBitmessageContext(ctx).cleanup();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
getActivity(),
|
ctx,
|
||||||
R.string.cleanup_notification_end,
|
R.string.cleanup_notification_end,
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show();
|
).show();
|
||||||
|
@ -45,6 +45,7 @@ import ch.dissem.apps.abit.util.Assets;
|
|||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||||
|
|
||||||
|
import static ch.dissem.apps.abit.repository.AndroidMessageRepository.LABEL_ARCHIVE;
|
||||||
import static ch.dissem.apps.abit.util.Strings.normalizeWhitespaces;
|
import static ch.dissem.apps.abit.util.Strings.normalizeWhitespaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +200,7 @@ public class SwipeableMessageAdapter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onGetSwipeReactionType(ViewHolder holder, int position, int x, int y) {
|
public int onGetSwipeReactionType(ViewHolder holder, int position, int x, int y) {
|
||||||
if (label == null || label.getType() == Label.Type.TRASH) {
|
if (label == LABEL_ARCHIVE || label.getType() == Label.Type.TRASH) {
|
||||||
return REACTION_CAN_SWIPE_LEFT | REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT;
|
return REACTION_CAN_SWIPE_LEFT | REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT;
|
||||||
}
|
}
|
||||||
return REACTION_CAN_SWIPE_BOTH_H;
|
return REACTION_CAN_SWIPE_BOTH_H;
|
||||||
@ -217,7 +218,7 @@ public class SwipeableMessageAdapter
|
|||||||
bgRes = R.drawable.bg_swipe_item_left;
|
bgRes = R.drawable.bg_swipe_item_left;
|
||||||
break;
|
break;
|
||||||
case DRAWABLE_SWIPE_RIGHT_BACKGROUND:
|
case DRAWABLE_SWIPE_RIGHT_BACKGROUND:
|
||||||
if (label == null || label.getType() == Label.Type.TRASH) {
|
if (label == LABEL_ARCHIVE || label.getType() == Label.Type.TRASH) {
|
||||||
bgRes = R.drawable.bg_swipe_item_neutral;
|
bgRes = R.drawable.bg_swipe_item_neutral;
|
||||||
} else {
|
} else {
|
||||||
bgRes = R.drawable.bg_swipe_item_right;
|
bgRes = R.drawable.bg_swipe_item_right;
|
||||||
|
@ -92,14 +92,12 @@ public class NewMessageNotification extends AbstractNotification {
|
|||||||
numberOfUnacknowledgedMessages) {
|
numberOfUnacknowledgedMessages) {
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
|
||||||
builder.setSmallIcon(R.drawable.ic_notification_new_message)
|
builder.setSmallIcon(R.drawable.ic_notification_new_message)
|
||||||
.setContentTitle(ctx.getString(R.string.n_new_messages, unacknowledged.size()))
|
.setContentTitle(ctx.getString(R.string.n_new_messages, numberOfUnacknowledgedMessages))
|
||||||
.setContentText(ctx.getString(R.string.app_name));
|
.setContentText(ctx.getString(R.string.app_name));
|
||||||
|
|
||||||
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
||||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||||
synchronized (unacknowledged) {
|
synchronized (unacknowledged) {
|
||||||
inboxStyle.setBigContentTitle(ctx.getString(R.string.n_new_messages,
|
|
||||||
numberOfUnacknowledgedMessages));
|
|
||||||
for (Plaintext msg : unacknowledged) {
|
for (Plaintext msg : unacknowledged) {
|
||||||
Spannable sb = new SpannableString(msg.getFrom() + " " + msg.getSubject());
|
Spannable sb = new SpannableString(msg.getFrom() + " " + msg.getSubject());
|
||||||
sb.setSpan(SPAN_EMPHASIS, 0, String.valueOf(msg.getFrom()).length(), Spannable
|
sb.setSpan(SPAN_EMPHASIS, 0, String.valueOf(msg.getFrom()).length(), Spannable
|
||||||
|
@ -48,6 +48,8 @@ import static java.lang.String.valueOf;
|
|||||||
public class AndroidMessageRepository extends AbstractMessageRepository {
|
public class AndroidMessageRepository extends AbstractMessageRepository {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AndroidMessageRepository.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AndroidMessageRepository.class);
|
||||||
|
|
||||||
|
public static final Label LABEL_ARCHIVE = new Label("archive", null, 0);
|
||||||
|
|
||||||
private static final String TABLE_NAME = "Message";
|
private static final String TABLE_NAME = "Message";
|
||||||
private static final String COLUMN_ID = "id";
|
private static final String COLUMN_ID = "id";
|
||||||
private static final String COLUMN_IV = "iv";
|
private static final String COLUMN_IV = "iv";
|
||||||
@ -82,6 +84,15 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
|||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Plaintext> findMessages(Label label) {
|
||||||
|
if (label == LABEL_ARCHIVE) {
|
||||||
|
return super.findMessages((Label) null);
|
||||||
|
} else {
|
||||||
|
return super.findMessages(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Label> findLabels(String where) {
|
public List<Label> findLabels(String where) {
|
||||||
List<Label> result = new LinkedList<>();
|
List<Label> result = new LinkedList<>();
|
||||||
|
|
||||||
@ -153,15 +164,18 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
|
|||||||
public int countUnread(Label label) {
|
public int countUnread(Label label) {
|
||||||
String[] args;
|
String[] args;
|
||||||
String where;
|
String where;
|
||||||
if (label != null) {
|
if (label == null){
|
||||||
where = "id IN (SELECT message_id FROM Message_Label WHERE label_id=?) AND ";
|
return 0;
|
||||||
|
}
|
||||||
|
if (label == LABEL_ARCHIVE) {
|
||||||
|
where = "";
|
||||||
args = new String[]{
|
args = new String[]{
|
||||||
label.getId().toString(),
|
|
||||||
Label.Type.UNREAD.name()
|
Label.Type.UNREAD.name()
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
where = "";
|
where = "id IN (SELECT message_id FROM Message_Label WHERE label_id=?) AND ";
|
||||||
args = new String[]{
|
args = new String[]{
|
||||||
|
label.getId().toString(),
|
||||||
Label.Type.UNREAD.name()
|
Label.Type.UNREAD.name()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user