1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
k-9/src/com/fsck/k9/activity/LauncherShortcuts.java
cketti d8e9c48177 Changed the way we use the activity stack
- removed launchMode attributes for all activities
- only use one activity task
- got rid of "managed back button" behavior
2012-09-10 17:24:34 +02:00

55 lines
1.7 KiB
Java

package com.fsck.k9.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import com.fsck.k9.Account;
import com.fsck.k9.BaseAccount;
import com.fsck.k9.R;
import com.fsck.k9.SearchSpecification;
public class LauncherShortcuts extends AccountList {
@Override
public void onCreate(Bundle icicle) {
// finish() immediately if we aren't supposed to be here
if (!Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
finish();
return;
}
super.onCreate(icicle);
}
@Override
protected boolean displaySpecialAccounts() {
return true;
}
@Override
protected void onAccountSelected(BaseAccount account) {
Intent shortcutIntent = null;
if (account instanceof SearchSpecification) {
shortcutIntent = MessageList.actionHandleAccountIntent(this, account.getDescription(),
(SearchSpecification) account);
} else {
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
true);
}
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
String description = account.getDescription();
if (description == null || description.length() == 0) {
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();
}
}