mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-03 10:16:45 +00:00
Added intent to set poll interval
This commit is contained in:
parent
3d632fd900
commit
a7ec00e6ea
3 changed files with 25 additions and 0 deletions
8
FAQ.md
8
FAQ.md
|
@ -2259,6 +2259,14 @@ To enable/disable a specific account:
|
|||
|
||||
Note that disabling an account will hide the account and all associated folders and messages.
|
||||
|
||||
To set the poll interval:
|
||||
|
||||
```
|
||||
(adb shell) adb shell am start-foreground-service -a eu.faircode.email.INTERVAL --ei minutes nnn
|
||||
```
|
||||
|
||||
Where *nnn* is one of 0, 15, 30, 60, 120, 240, 480, 1440.
|
||||
|
||||
You can automatically send commands with for example [Tasker](https://tasker.joaoapps.com/userguide/en/intents.html):
|
||||
|
||||
```
|
||||
|
|
|
@ -355,6 +355,7 @@
|
|||
<action android:name="${applicationId}.POLL" />
|
||||
<action android:name="${applicationId}.ENABLE" />
|
||||
<action android:name="${applicationId}.DISABLE" />
|
||||
<action android:name="${applicationId}.INTERVAL" />
|
||||
<action android:name="${applicationId}.DISCONNECT.ME" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ServiceExternal extends Service {
|
|||
private static final String ACTION_POLL = BuildConfig.APPLICATION_ID + ".POLL";
|
||||
private static final String ACTION_ENABLE = BuildConfig.APPLICATION_ID + ".ENABLE";
|
||||
private static final String ACTION_DISABLE = BuildConfig.APPLICATION_ID + ".DISABLE";
|
||||
private static final String ACTION_INTERVAL = BuildConfig.APPLICATION_ID + ".INTERVAL";
|
||||
private static final String ACTION_DISCONNECT_ME = BuildConfig.APPLICATION_ID + ".DISCONNECT.ME";
|
||||
|
||||
static final int PI_WIDGET_ENABLE = 1;
|
||||
|
@ -48,6 +49,7 @@ public class ServiceExternal extends Service {
|
|||
// adb shell am start-foreground-service -a eu.faircode.email.POLL --es account Gmail
|
||||
// adb shell am start-foreground-service -a eu.faircode.email.ENABLE --es account Gmail
|
||||
// adb shell am start-foreground-service -a eu.faircode.email.DISABLE --es account Gmail
|
||||
// adb shell am start-foreground-service -a eu.faircode.email.INTERVAL --ei minutes {0, 15, 30, 60, 120, 240, 480, 1440}
|
||||
// adb shell am start-foreground-service -a eu.faircode.email.DISCONNECT
|
||||
|
||||
private static final ExecutorService executor =
|
||||
|
@ -96,6 +98,9 @@ public class ServiceExternal extends Service {
|
|||
case ACTION_DISABLE:
|
||||
set(context, intent);
|
||||
break;
|
||||
case ACTION_INTERVAL:
|
||||
interval(context, intent);
|
||||
break;
|
||||
case ACTION_DISCONNECT_ME:
|
||||
disconnect(context, intent);
|
||||
break;
|
||||
|
@ -163,6 +168,17 @@ public class ServiceExternal extends Service {
|
|||
ServiceSynchronize.eval(context, "external poll account=" + accountName);
|
||||
}
|
||||
|
||||
private static void interval(Context context, Intent intent) {
|
||||
int minutes = intent.getIntExtra("minutes", 0);
|
||||
int[] values = context.getResources().getIntArray(R.array.pollIntervalValues);
|
||||
for (int value : values)
|
||||
if (value >= minutes) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("poll_interval", value).apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void set(Context context, Intent intent) {
|
||||
String accountName = intent.getStringExtra("account");
|
||||
boolean enabled = ACTION_ENABLE.equals(intent.getAction());
|
||||
|
|
Loading…
Reference in a new issue