Added force sync

This commit is contained in:
M66B 2019-08-12 17:02:34 +02:00
parent eacb162de4
commit fe7887a114
6 changed files with 36 additions and 10 deletions

11
FAQ.md
View File

@ -201,6 +201,7 @@ FairEmail follows all the best practices for an email client as decribed in [thi
* [(120) Why are new message notifications not removed on opening the app?](#user-content-faq120)
* [(121) How are messages grouped into a conversation?](#user-content-faq121)
* [(122) Why is the recipient name/email address show with a warning color?](#user-content-faq122)
* [(123) What does 'force sync'?](#user-content-faq123)
[I have another question.](#support)
@ -2090,6 +2091,16 @@ Mostly this indicates that the message was received *via* an account with anothe
<br />
<a name="faq123"></a>
**(123) What does 'force sync'?**
FairEmail will wait a fixed time after connectivity changes
and will use a logarithmic back-off time after failing to connect to an account to prevent from being locked out.
*Force sync* will reset all timers and restart the synchronization service.
This should not normally be used.
<br />
## Support
If you have another question, want to request a feature or report a bug, you can use [this forum](https://forum.xda-developers.com/android/apps-games/source-email-t3824168).

View File

@ -278,12 +278,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
drawerLayout.closeDrawer(drawerContainer);
onMenuSetup();
}
}, new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawer(drawerContainer);
onReset();
}
}));
madapter.set(menus);
@ -938,10 +932,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Helper.view(this, getIntentOtherApps());
}
private void onReset() {
ServiceSynchronize.reset(this);
}
private void onDebugInfo() {
new SimpleTask<Long>() {
@Override

View File

@ -2488,6 +2488,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_select_all).setVisible(!outbox &&
(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER));
menu.findItem(R.id.menu_force_sync).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);
super.onPrepareOptionsMenu(menu);
}
@ -2562,6 +2564,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onMenuSelectAll();
return true;
case R.id.menu_force_sync:
onMenuForceSync();
return true;
default:
return super.onOptionsItemSelected(item);
}
@ -2662,6 +2668,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
});
}
private void onMenuForceSync() {
ServiceSynchronize.reset(getContext());
ToastEx.makeText(getContext(), R.string.title_executing, Toast.LENGTH_LONG).show();
}
private void updateState(List<TupleFolderEx> folders) {
Log.i("Folder state updated count=" + folders.size());

View File

@ -1554,6 +1554,13 @@ public class ServiceSynchronize extends ServiceBase {
}
static void reset(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean enabled = prefs.getBoolean("enabled", true);
int pollInterval = prefs.getInt("poll_interval", 0);
if (!enabled || pollInterval > 0) {
ServiceSynchronize.sync = true;
oneshot = true;
}
ContextCompat.startForegroundService(context,
new Intent(context, ServiceSynchronize.class)
.setAction("reset"));

View File

@ -94,4 +94,10 @@
android:icon="@drawable/baseline_format_size_24"
android:title="@string/title_select_all"
app:showAsAction="never" />
<item
android:id="@+id/menu_force_sync"
android:icon="@drawable/baseline_sync_24"
android:title="@string/title_force_sync"
app:showAsAction="never" />
</menu>

View File

@ -585,6 +585,7 @@
<string name="title_compact">Compact view</string>
<string name="title_zoom">Text size</string>
<string name="title_select_all">Select all</string>
<string name="title_force_sync">Force sync</string>
<string name="title_previous">Previous</string>
<string name="title_next">Next</string>