2010-07-07 12:17:13 -04:00
|
|
|
package com.fsck.k9.activity;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
|
|
|
|
import com.fsck.k9.Account;
|
2012-01-31 21:07:19 -05:00
|
|
|
import com.fsck.k9.BaseAccount;
|
2010-07-07 12:17:13 -04:00
|
|
|
import com.fsck.k9.R;
|
2012-11-26 18:50:32 -05:00
|
|
|
import com.fsck.k9.search.SearchAccount;
|
2010-07-07 12:17:13 -04:00
|
|
|
|
2012-02-07 14:19:10 -05:00
|
|
|
public class LauncherShortcuts extends AccountList {
|
2010-07-07 12:17:13 -04:00
|
|
|
@Override
|
2011-02-06 17:09:48 -05:00
|
|
|
public void onCreate(Bundle icicle) {
|
2010-07-07 12:17:13 -04:00
|
|
|
// finish() immediately if we aren't supposed to be here
|
2011-02-06 17:09:48 -05:00
|
|
|
if (!Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
|
2010-07-07 12:17:13 -04:00
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-07 14:19:10 -05:00
|
|
|
super.onCreate(icicle);
|
2010-07-07 12:17:13 -04:00
|
|
|
}
|
|
|
|
|
2012-02-07 14:19:10 -05:00
|
|
|
@Override
|
|
|
|
protected boolean displaySpecialAccounts() {
|
|
|
|
return true;
|
2010-07-07 12:17:13 -04:00
|
|
|
}
|
|
|
|
|
2012-02-07 14:19:10 -05:00
|
|
|
@Override
|
|
|
|
protected void onAccountSelected(BaseAccount account) {
|
2012-01-31 21:07:19 -05:00
|
|
|
Intent shortcutIntent = null;
|
|
|
|
|
2012-11-26 18:50:32 -05:00
|
|
|
if (account instanceof SearchAccount) {
|
|
|
|
SearchAccount searchAccount = (SearchAccount) account;
|
|
|
|
shortcutIntent = MessageList.shortcutIntent(this, searchAccount.getId());
|
2012-01-31 21:07:19 -05:00
|
|
|
} else {
|
2012-02-07 14:19:10 -05:00
|
|
|
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
|
|
|
true);
|
2012-01-31 21:07:19 -05:00
|
|
|
}
|
2010-07-07 12:17:13 -04:00
|
|
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
|
|
|
String description = account.getDescription();
|
2011-02-06 17:09:48 -05:00
|
|
|
if (description == null || description.length() == 0) {
|
2010-07-07 12:17:13 -04:00
|
|
|
description = account.getEmail();
|
|
|
|
}
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, description);
|
|
|
|
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
|
|
|
|
|
|
|
|
setResult(RESULT_OK, intent);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|