Browse Source

Merge branch 'develop' into 'master'

Prepare v1.2.0
See merge request dystopia-project/simple-email!9
main
Distopico Vegan 6 years ago
parent
commit
54ff10bb1e
3 changed files with 37 additions and 25 deletions
  1. +31
    -19
      app/src/main/java/org/dystopia/email/FragmentMessages.java
  2. +5
    -5
      app/src/main/java/org/dystopia/email/ServiceSynchronize.java
  3. +1
    -1
      app/src/main/res/values/strings.xml

+ 31
- 19
app/src/main/java/org/dystopia/email/FragmentMessages.java View File

@ -22,6 +22,8 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -42,6 +44,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
@ -341,8 +344,12 @@ public class FragmentMessages extends FragmentEx {
View itemView = viewHolder.itemView; View itemView = viewHolder.itemView;
int margin = Math.round(12 * (getResources().getDisplayMetrics().density)); int margin = Math.round(12 * (getResources().getDisplayMetrics().density));
Paint color = new Paint();
color.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
if (dX > margin) { if (dX > margin) {
canvas.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
(float) itemView.getBottom(), color);
// Right swipe // Right swipe
Drawable d = getResources().getDrawable( Drawable d = getResources().getDrawable(
inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_archive_24, inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_archive_24,
@ -351,8 +358,12 @@ public class FragmentMessages extends FragmentEx {
d.setBounds(itemView.getLeft() + margin, itemView.getTop() + padding / 2, d.setBounds(itemView.getLeft() + margin, itemView.getTop() + padding / 2,
itemView.getLeft() + margin + d.getIntrinsicWidth(), itemView.getLeft() + margin + d.getIntrinsicWidth(),
itemView.getTop() + padding / 2 + d.getIntrinsicHeight()); itemView.getTop() + padding / 2 + d.getIntrinsicHeight());
d.setTint(Color.WHITE);
d.draw(canvas); d.draw(canvas);
} else if (dX < -margin) { } else if (dX < -margin) {
canvas.drawRect((float) itemView.getRight() + dX, (float) itemView.getTop(),
(float) itemView.getRight(), (float) itemView.getBottom(), color);
// Left swipe // Left swipe
Drawable d = getResources().getDrawable( Drawable d = getResources().getDrawable(
inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_delete_24, inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_delete_24,
@ -361,6 +372,7 @@ public class FragmentMessages extends FragmentEx {
d.setBounds(itemView.getLeft() + itemView.getWidth() - d.getIntrinsicWidth() - margin, d.setBounds(itemView.getLeft() + itemView.getWidth() - d.getIntrinsicWidth() - margin,
itemView.getTop() + padding / 2, itemView.getLeft() + itemView.getWidth() - margin, itemView.getTop() + padding / 2, itemView.getLeft() + itemView.getWidth() - margin,
itemView.getTop() + padding / 2 + d.getIntrinsicHeight()); itemView.getTop() + padding / 2 + d.getIntrinsicHeight());
d.setTint(Color.WHITE);
d.draw(canvas); d.draw(canvas);
} }
@ -1220,36 +1232,36 @@ public class FragmentMessages extends FragmentEx {
// - no more non archived/sent messages // - no more non archived/sent messages
if (count == 0) { if (count == 0) {
finish();
finish();
} }
} }
} else { } else {
ViewModelMessages model =
ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
model.setMessages(messages);
ViewModelMessages model =
ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
model.setMessages(messages);
} }
Log.i(Helper.TAG, "Submit messages=" + messages.size());
adapter.submitList(messages);
Log.i(Helper.TAG, "Submit messages=" + messages.size());
adapter.submitList(messages);
boolean searching = (searchCallback != null && searchCallback.isSearching());
boolean searching = (searchCallback != null && searchCallback.isSearching());
if (!searching) {
pbWait.setVisibility(View.GONE);
}
grpReady.setVisibility(View.VISIBLE);
if (!searching) {
pbWait.setVisibility(View.GONE);
}
grpReady.setVisibility(View.VISIBLE);
if (messages.size() == 0) {
if (searchCallback == null) {
tvNoEmail.setVisibility(View.VISIBLE);
}
if (messages.size() == 0) {
if (searchCallback == null) {
tvNoEmail.setVisibility(View.VISIBLE);
}
rvMessage.setVisibility(View.GONE); rvMessage.setVisibility(View.GONE);
} else { } else {
tvNoEmail.setVisibility(View.GONE);
rvMessage.setVisibility(View.VISIBLE);
tvNoEmail.setVisibility(View.GONE);
rvMessage.setVisibility(View.VISIBLE);
} }
}
});
}
});
} }
private void handleExpand(long id) { private void handleExpand(long id) {


+ 5
- 5
app/src/main/java/org/dystopia/email/ServiceSynchronize.java View File

@ -189,11 +189,11 @@ public class ServiceSynchronize extends LifecycleService {
Long accountKey = message.account; Long accountKey = message.account;
List<TupleNotification> msgList = new ArrayList<>(); List<TupleNotification> msgList = new ArrayList<>();
if (messagesByAccount.indexOfKey(accountKey) != -1) {
msgList = messagesByAccount.get(accountKey);
if (messagesByAccount.indexOfKey(accountKey) >= 0) {
msgList = messagesByAccount.get(accountKey, msgList);
} }
if (accounts.indexOfKey(accountKey) == -1) {
if (accounts.indexOfKey(accountKey) < 0) {
accounts.put(accountKey, accounts.put(accountKey,
new Pair<String, Integer>(message.accountName, message.accountColor)); new Pair<String, Integer>(message.accountName, message.accountColor));
} }
@ -213,7 +213,7 @@ public class ServiceSynchronize extends LifecycleService {
List<Integer> toRemove = new ArrayList<>(); List<Integer> toRemove = new ArrayList<>();
String tag = "unseen-" + accountId; String tag = "unseen-" + accountId;
if (notifying.indexOfKey(accountId) != -1) {
if (notifying.indexOfKey(accountId) >= 0) {
toRemove = notifying.get(accountId); toRemove = notifying.get(accountId);
} }
@ -539,7 +539,7 @@ public class ServiceSynchronize extends LifecycleService {
List<Notification> notifications = new ArrayList<>(); List<Notification> notifications = new ArrayList<>();
Integer size = messages.size(); Integer size = messages.size();
if (size == 0) {
if (size == 0 || account == null) {
return notifications; return notifications;
} }


+ 1
- 1
app/src/main/res/values/strings.xml View File

@ -1,7 +1,7 @@
<resources> <resources>
<string name="app_name" translatable="false">SimpleEmail</string> <string name="app_name" translatable="false">SimpleEmail</string>
<string name="app_label" translatable="false">Email</string> <string name="app_label" translatable="false">Email</string>
<string name="app_copyright">Copyright &#x24B8; 2018 by M. Bokhorst\nCopyright &#x24B8; 2018 by Distopico (dystopia project) and contributors</string>
<string name="app_copyright" translatable="false">Copyright &#x24B8; 2018 by M. Bokhorst\nCopyright &#x24B8; 2018 by Distopico (dystopia project) and contributors</string>
<string name="app_eula" translatable="false">This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.</string> <string name="app_eula" translatable="false">This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.</string>
<string name="channel_service">Service</string> <string name="channel_service">Service</string>


Loading…
Cancel
Save