Folder type specific scroll to top

This commit is contained in:
M66B 2021-08-22 20:12:13 +02:00
parent 49df3bbb4c
commit 3755dc4d3b
3 changed files with 27 additions and 10 deletions

View File

@ -41,6 +41,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.util.TypedValue;
import android.view.LayoutInflater;
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 value = updatedFolders.contains(folder);
boolean isFolderUpdated(Long folder, String type) {
Pair<Long, String> key = new Pair<>(
folder == null ? -1L : folder,
folder == null ? type : null);
boolean value = updatedFolders.contains(key);
if (value)
updatedFolders.remove(folder);
updatedFolders.remove(key);
return value;
}
private void onNewMessage(Intent intent) {
long folder = intent.getLongExtra("folder", -1);
String type = intent.getStringExtra("type");
boolean unified = intent.getBooleanExtra("unified", false);
if (!updatedFolders.contains(folder))
updatedFolders.add(folder);
if (unified && !updatedFolders.contains(-1L))
updatedFolders.add(-1L);
Pair<Long, String> pfolder = new Pair<>(folder, null);
if (!updatedFolders.contains(pfolder))
updatedFolders.add(pfolder);
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() {

View File

@ -3918,8 +3918,11 @@ class Core {
message.received > account.created) {
Intent report = new Intent(ActivityView.ACTION_NEW_MESSAGE);
report.putExtra("folder", folder.id);
report.putExtra("type", folder.type);
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);
lbm.sendBroadcast(report);

View File

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