Search in sources :

Example 6 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project k-9 by k9mail.

the class MessageList method decodeExtras.

private boolean decodeExtras(Intent intent) {
    String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null) {
        Uri uri = intent.getData();
        List<String> segmentList = uri.getPathSegments();
        String accountId = segmentList.get(0);
        Collection<Account> accounts = Preferences.getPreferences(this).getAvailableAccounts();
        for (Account account : accounts) {
            if (String.valueOf(account.getAccountNumber()).equals(accountId)) {
                String folderName = segmentList.get(1);
                String messageUid = segmentList.get(2);
                mMessageReference = new MessageReference(account.getUuid(), folderName, messageUid, null);
                break;
            }
        }
    } else if (ACTION_SHORTCUT.equals(action)) {
        // Handle shortcut intents
        String specialFolder = intent.getStringExtra(EXTRA_SPECIAL_FOLDER);
        if (SearchAccount.UNIFIED_INBOX.equals(specialFolder)) {
            mSearch = SearchAccount.createUnifiedInboxAccount(this).getRelatedSearch();
        } else if (SearchAccount.ALL_MESSAGES.equals(specialFolder)) {
            mSearch = SearchAccount.createAllMessagesAccount(this).getRelatedSearch();
        }
    } else if (intent.getStringExtra(SearchManager.QUERY) != null) {
        // check if this intent comes from the system search ( remote )
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            //Query was received from Search Dialog
            String query = intent.getStringExtra(SearchManager.QUERY).trim();
            mSearch = new LocalSearch(getString(R.string.search_results));
            mSearch.setManualSearch(true);
            mNoThreading = true;
            mSearch.or(new SearchCondition(SearchField.SENDER, Attribute.CONTAINS, query));
            mSearch.or(new SearchCondition(SearchField.SUBJECT, Attribute.CONTAINS, query));
            mSearch.or(new SearchCondition(SearchField.MESSAGE_CONTENTS, Attribute.CONTAINS, query));
            Bundle appData = intent.getBundleExtra(SearchManager.APP_DATA);
            if (appData != null) {
                mSearch.addAccountUuid(appData.getString(EXTRA_SEARCH_ACCOUNT));
                // searches started from a folder list activity will provide an account, but no folder
                if (appData.getString(EXTRA_SEARCH_FOLDER) != null) {
                    mSearch.addAllowedFolder(appData.getString(EXTRA_SEARCH_FOLDER));
                }
            } else {
                mSearch.addAccountUuid(LocalSearch.ALL_ACCOUNTS);
            }
        }
    } else if (intent.hasExtra(EXTRA_SEARCH_OLD)) {
        mSearch = intent.getParcelableExtra(EXTRA_SEARCH_OLD);
        mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false);
    } else {
        // regular LocalSearch object was passed
        mSearch = intent.hasExtra(EXTRA_SEARCH) ? ParcelableUtil.unmarshall(intent.getByteArrayExtra(EXTRA_SEARCH), LocalSearch.CREATOR) : null;
        mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false);
    }
    if (mMessageReference == null) {
        String messageReferenceString = intent.getStringExtra(EXTRA_MESSAGE_REFERENCE);
        mMessageReference = MessageReference.parse(messageReferenceString);
    }
    if (mMessageReference != null) {
        mSearch = new LocalSearch();
        mSearch.addAccountUuid(mMessageReference.getAccountUuid());
        mSearch.addAllowedFolder(mMessageReference.getFolderName());
    }
    if (mSearch == null) {
        // We've most likely been started by an old unread widget
        String accountUuid = intent.getStringExtra("account");
        String folderName = intent.getStringExtra("folder");
        mSearch = new LocalSearch(folderName);
        mSearch.addAccountUuid((accountUuid == null) ? "invalid" : accountUuid);
        if (folderName != null) {
            mSearch.addAllowedFolder(folderName);
        }
    }
    Preferences prefs = Preferences.getPreferences(getApplicationContext());
    String[] accountUuids = mSearch.getAccountUuids();
    if (mSearch.searchAllAccounts()) {
        List<Account> accounts = prefs.getAccounts();
        mSingleAccountMode = (accounts.size() == 1);
        if (mSingleAccountMode) {
            mAccount = accounts.get(0);
        }
    } else {
        mSingleAccountMode = (accountUuids.length == 1);
        if (mSingleAccountMode) {
            mAccount = prefs.getAccount(accountUuids[0]);
        }
    }
    mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1);
    if (mSingleAccountMode && (mAccount == null || !mAccount.isAvailable(this))) {
        Timber.i("not opening MessageList of unavailable account");
        onAccountUnavailable();
        return false;
    }
    if (mSingleFolderMode) {
        mFolderName = mSearch.getFolderNames().get(0);
    }
    // now we know if we are in single account mode and need a subtitle
    mActionBarSubTitle.setVisibility((!mSingleFolderMode) ? View.GONE : View.VISIBLE);
    return true;
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) SearchCondition(com.fsck.k9.search.SearchSpecification.SearchCondition) LocalSearch(com.fsck.k9.search.LocalSearch) Bundle(android.os.Bundle) Preferences(com.fsck.k9.Preferences) Uri(android.net.Uri)

Example 7 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project k-9 by k9mail.

the class MessageList method openMessage.

@Override
public void openMessage(MessageReference messageReference) {
    Preferences prefs = Preferences.getPreferences(getApplicationContext());
    Account account = prefs.getAccount(messageReference.getAccountUuid());
    String folderName = messageReference.getFolderName();
    if (folderName.equals(account.getDraftsFolderName())) {
        MessageActions.actionEditDraft(this, messageReference);
    } else {
        mMessageViewContainer.removeView(mMessageViewPlaceHolder);
        if (mMessageListFragment != null) {
            mMessageListFragment.setActiveMessage(messageReference);
        }
        MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.message_view_container, fragment);
        mMessageViewFragment = fragment;
        ft.commit();
        if (mDisplayMode != DisplayMode.SPLIT_VIEW) {
            showMessageView();
        }
    }
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) FragmentTransaction(android.app.FragmentTransaction) MessageViewFragment(com.fsck.k9.ui.messageview.MessageViewFragment) Preferences(com.fsck.k9.Preferences)

Example 8 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project k-9 by k9mail.

the class MessageProviderTest method createAccount.

private void createAccount() {
    Preferences preferences = Preferences.getPreferences(getMockContext());
    Account account = preferences.newAccount();
    account.setDescription("TestAccount");
    account.setChipColor(10);
    account.setStoreUri("imap://user@domain.com/");
    account.save(preferences);
}
Also used : Account(com.fsck.k9.Account) Preferences(com.fsck.k9.Preferences)

Example 9 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class RecordManagerReadOnlyImpl method getPreferences.

private Preferences getPreferences(String orcid) {
    Preferences preferences = new Preferences();
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    org.orcid.jaxb.model.common_v2.Locale profileEntityLocale = profile.getLocale();
    if (profileEntityLocale != null) {
        preferences.setLocale(profileEntityLocale);
    }
    return preferences;
}
Also used : Preferences(org.orcid.jaxb.model.record_v2.Preferences) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 10 with Preferences

use of org.orcid.jaxb.model.record_v2.Preferences in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Aggregations

Preferences (com.fsck.k9.Preferences)17 Account (com.fsck.k9.Account)13 Test (org.junit.Test)12 IOException (java.io.IOException)5 Preferences (org.apereo.portal.soffit.model.v1_0.Preferences)5 Preferences (org.orcid.jaxb.model.record_v2.Preferences)5 StorageEditor (com.fsck.k9.preferences.StorageEditor)4 SearchAccount (com.fsck.k9.search.SearchAccount)4 InvalidSettingValueException (com.fsck.k9.preferences.Settings.InvalidSettingValueException)3 Storage (com.fsck.k9.preferences.Storage)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Bearer (org.apereo.portal.soffit.model.v1_0.Bearer)3 Definition (org.apereo.portal.soffit.model.v1_0.Definition)3 PortalRequest (org.apereo.portal.soffit.model.v1_0.PortalRequest)3 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 Uri (android.net.Uri)2 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)2 InputStreamReader (java.io.InputStreamReader)2