1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00
k-9/src/com/fsck/k9/service/RemoteControlReceiver.java
Jesse Vincent 12d1097a24 Big, scary massive "ant astyle" to get us back to something
approximating AOSP coding standards.
2011-02-06 17:09:48 -05:00

51 lines
1.8 KiB
Java

package com.fsck.k9.service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.remotecontrol.K9RemoteControl;
import com.fsck.k9.Preferences;
import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
public class RemoteControlReceiver extends CoreReceiver {
@Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "RemoteControlReceiver.onReceive" + intent);
if (K9RemoteControl.K9_SET.equals(intent.getAction())) {
RemoteControlService.set(context, intent, tmpWakeLockId);
tmpWakeLockId = null;
} else if (K9RemoteControl.K9_REQUEST_ACCOUNTS.equals(intent.getAction())) {
try {
Preferences preferences = Preferences.getPreferences(context);
Account[] accounts = preferences.getAccounts();
String[] uuids = new String[accounts.length];
String[] descriptions = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) {
//warning: account may not be isAvailable()
Account account = accounts[i];
uuids[i] = account.getUuid();
descriptions[i] = account.getDescription();
}
Bundle bundle = getResultExtras(true);
bundle.putStringArray(K9_ACCOUNT_UUIDS, uuids);
bundle.putStringArray(K9_ACCOUNT_DESCRIPTIONS, descriptions);
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Could not handle K9_RESPONSE_INTENT", e);
}
}
return tmpWakeLockId;
}
}