mirror of https://github.com/M66B/FairEmail.git
Always listen for new messages
This commit is contained in:
parent
6c6e260be8
commit
43ac5a69a3
|
@ -141,6 +141,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState, false);
|
super.onCreate(savedInstanceState, false);
|
||||||
|
|
||||||
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
|
||||||
|
lbm.registerReceiver(creceiver, new IntentFilter(ACTION_NEW_MESSAGE));
|
||||||
|
|
||||||
if (savedInstanceState != null)
|
if (savedInstanceState != null)
|
||||||
searching = savedInstanceState.getBoolean("fair:searching");
|
searching = savedInstanceState.getBoolean("fair:searching");
|
||||||
|
|
||||||
|
@ -617,7 +620,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
iff.addAction(ACTION_EDIT_ANSWER);
|
iff.addAction(ACTION_EDIT_ANSWER);
|
||||||
iff.addAction(ACTION_EDIT_RULES);
|
iff.addAction(ACTION_EDIT_RULES);
|
||||||
iff.addAction(ACTION_EDIT_RULE);
|
iff.addAction(ACTION_EDIT_RULE);
|
||||||
iff.addAction(ACTION_NEW_MESSAGE);
|
|
||||||
lbm.registerReceiver(receiver, iff);
|
lbm.registerReceiver(receiver, iff);
|
||||||
|
|
||||||
checkUpdate(false);
|
checkUpdate(false);
|
||||||
|
@ -631,6 +633,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
lbm.unregisterReceiver(receiver);
|
lbm.unregisterReceiver(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
unregisterReceiver(creceiver);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
@ -1131,6 +1140,32 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver creceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
onNewMessage(intent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private List<Long> updatedFolders = new ArrayList<>();
|
||||||
|
|
||||||
|
boolean isFolderUpdated(long folder) {
|
||||||
|
boolean value = updatedFolders.contains(folder);
|
||||||
|
if (value)
|
||||||
|
updatedFolders.remove(folder);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onNewMessage(Intent intent) {
|
||||||
|
long folder = intent.getLongExtra("folder", -1);
|
||||||
|
boolean unified = intent.getBooleanExtra("unified", false);
|
||||||
|
|
||||||
|
if (!updatedFolders.contains(folder))
|
||||||
|
updatedFolders.add(folder);
|
||||||
|
if (unified && !updatedFolders.contains(-1L))
|
||||||
|
updatedFolders.add(-1L);
|
||||||
|
}
|
||||||
|
|
||||||
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
@ -1155,8 +1190,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
onEditRules(intent);
|
onEditRules(intent);
|
||||||
else if (ACTION_EDIT_RULE.equals(action))
|
else if (ACTION_EDIT_RULE.equals(action))
|
||||||
onEditRule(intent);
|
onEditRule(intent);
|
||||||
else if (ACTION_NEW_MESSAGE.equals(action))
|
|
||||||
onNewMessage(intent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1261,25 +1294,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> updatedFolders = new ArrayList<>();
|
|
||||||
|
|
||||||
boolean isFolderUpdated(long folder) {
|
|
||||||
boolean value = updatedFolders.contains(folder);
|
|
||||||
if (value)
|
|
||||||
updatedFolders.remove(folder);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onNewMessage(Intent intent) {
|
|
||||||
long folder = intent.getLongExtra("folder", -1);
|
|
||||||
boolean unified = intent.getBooleanExtra("unified", false);
|
|
||||||
|
|
||||||
if (!updatedFolders.contains(folder))
|
|
||||||
updatedFolders.add(folder);
|
|
||||||
if (unified && !updatedFolders.contains(-1L))
|
|
||||||
updatedFolders.add(-1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UpdateInfo {
|
private class UpdateInfo {
|
||||||
String tag_name; // version
|
String tag_name; // version
|
||||||
String html_url;
|
String html_url;
|
||||||
|
|
Loading…
Reference in New Issue