Folder type specific scroll to top

pull/204/head
M66B 3 years ago
parent 49df3bbb4c
commit 3755dc4d3b

@ -41,6 +41,7 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Pair;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -1652,23 +1653,36 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
}; };
private List<Long> updatedFolders = new ArrayList<>(); private List<Pair<Long, String>> updatedFolders = new ArrayList<>();
boolean isFolderUpdated(long folder) { boolean isFolderUpdated(Long folder, String type) {
boolean value = updatedFolders.contains(folder); Pair<Long, String> key = new Pair<>(
folder == null ? -1L : folder,
folder == null ? type : null);
boolean value = updatedFolders.contains(key);
if (value) if (value)
updatedFolders.remove(folder); updatedFolders.remove(key);
return value; return value;
} }
private void onNewMessage(Intent intent) { private void onNewMessage(Intent intent) {
long folder = intent.getLongExtra("folder", -1); long folder = intent.getLongExtra("folder", -1);
String type = intent.getStringExtra("type");
boolean unified = intent.getBooleanExtra("unified", false); boolean unified = intent.getBooleanExtra("unified", false);
if (!updatedFolders.contains(folder)) Pair<Long, String> pfolder = new Pair<>(folder, null);
updatedFolders.add(folder); if (!updatedFolders.contains(pfolder))
if (unified && !updatedFolders.contains(-1L)) updatedFolders.add(pfolder);
updatedFolders.add(-1L);
Pair<Long, String> ptype = new Pair<>(-1L, type);
if (!updatedFolders.contains(ptype))
updatedFolders.add(ptype);
if (unified) {
Pair<Long, String> punified = new Pair<>(-1L, null);
if (!updatedFolders.contains(punified))
updatedFolders.add(punified);
}
} }
private BroadcastReceiver receiver = new BroadcastReceiver() { private BroadcastReceiver receiver = new BroadcastReceiver() {

@ -3918,8 +3918,11 @@ class Core {
message.received > account.created) { message.received > account.created) {
Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE); Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE);
report.putExtra("folder", folder.id); report.putExtra("folder", folder.id);
report.putExtra("type", folder.type);
report.putExtra("unified", folder.unified); report.putExtra("unified", folder.unified);
Log.i("Report new id=" + message.id + " folder=" + folder.name + " unified=" + folder.unified); Log.i("Report new id=" + message.id +
" folder=" + folder.type + ":" + folder.name +
" unified=" + folder.unified);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(report); lbm.sendBroadcast(report);

@ -5066,7 +5066,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (autoscroll) { if (autoscroll) {
ActivityView activity = (ActivityView) getActivity(); ActivityView activity = (ActivityView) getActivity();
if (activity != null && if (activity != null &&
activity.isFolderUpdated(viewType == AdapterMessage.ViewType.UNIFIED ? -1L : folder)) activity.isFolderUpdated(viewType == AdapterMessage.ViewType.UNIFIED ? null : folder, type))
adapter.gotoTop(); adapter.gotoTop();
} }
} }

Loading…
Cancel
Save