Example usage for android.app SearchManager QUERY

List of usage examples for android.app SearchManager QUERY

Introduction

In this page you can find the example usage for android.app SearchManager QUERY.

Prototype

String QUERY

To view the source code for android.app SearchManager QUERY.

Click Source Link

Document

Intent extra data key: Use this key with android.content.Intent#getStringExtra content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.

Usage

From source file:com.kyakujin.android.tagnotepad.ui.NoteActivity.java

/**
 * ?//from  w  w w  .  j av a  2s .co  m
 *
 * @param intent the intent
 */
private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        String tagname = null;
        final Bundle bundle = intent.getBundleExtra(SearchManager.APP_DATA);
        if (bundle != null) {
            // ????????????????
            // ??"Tag_A"????????????
            // ???????
            // "Tag_A"?where????
            tagname = bundle.getString(Config.SELECTED_TAGNAME);
        }

        doSearch(query, tagname);
    }
}

From source file:org.jsharkey.oilcan.BrowserActivity.java

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.act_browse);

    scriptdb = new ScriptDatabase(this);
    scriptdb.onUpgrade(scriptdb.getWritableDatabase(), -10, 10);

    webview = (WebView) findViewById(R.id.browse_webview);

    WebSettings settings = webview.getSettings();
    settings.setSavePassword(false);/*from   ww w .j a v a2 s  .  co m*/
    settings.setSaveFormData(false);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

    FrameLayout zoomholder = (FrameLayout) this.findViewById(R.id.browse_zoom);
    zoomholder.addView(webview.getZoomControls());
    webview.getZoomControls().setVisibility(View.GONE);

    webview.setWebViewClient(new OilCanClient());
    webview.setWebChromeClient(new OilCanChrome());

    webview.addJavascriptInterface(new IntentHelper(), "intentHelper");

    // load the last-viewed page into browser
    String url = "http://m.half.com/";
    if (icicle != null && icicle.containsKey(LAST_VIEWED))
        url = icicle.getString(LAST_VIEWED);

    // or watch for incoming requested urls
    if (getIntent().getExtras() != null && getIntent().getExtras().containsKey(SearchManager.QUERY))
        url = getIntent().getStringExtra(SearchManager.QUERY);

    webview.loadUrl(url);

}

From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivity.java

/**
 * Parse intent - ACTION_SEARCH or ACTION_VIEW
 * @param intent Intent object/*from  w ww .  j ava2  s .  c  o  m*/
 */
protected void parseIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String searchQuery = intent.getStringExtra(SearchManager.QUERY);
        if (searchQuery != null)
            launchSearch(searchQuery, ticketManager.addIntent(intent));
    }
    if (Intent.ACTION_VIEW.equals(intent.getAction()) && (intent.getData() != null))
        viewUri(intent.getData(), ticketManager.addIntent(intent));

}

From source file:com.borqs.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    Log.i("OpenSearchSearchEng", "startSearch, query: " + query);
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {/*ww  w. j  a va2 s. c  om*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);/*  w  ww .  j  a  va  2  s .c  om*/
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    if (!UIUtils.isHoneycombTablet(this)) {
        final CharSequence title = getString(R.string.title_search_query, mQuery);
        setTitle(title);
    }

    mAdapter.notifyDataSetChanged();

    mViewPager.setCurrentItem(0);
}

From source file:com.pindroid.activity.BrowseBookmarks.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_bookmarks);

    Intent intent = getIntent();/*from  w  w w. j av a 2s. c om*/

    Uri data = intent.getData();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    if (fm.findFragmentById(R.id.listcontent) == null) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);

            if (searchData != null) {
                tagname = searchData.getString("tagname");
                app.setUsername(searchData.getString("username"));
                unread = searchData.getBoolean("unread");
            }

            query = intent.getStringExtra(SearchManager.QUERY);

            if (intent.hasExtra("username")) {
                app.setUsername(intent.getStringExtra("username"));
            }

            if (data != null) {
                feed = data.getQueryParameter("feed");

                if (data.getUserInfo() != null) {
                    app.setUsername(data.getUserInfo());
                }
            }
        } else {
            if (data != null) {
                tagname = data.getQueryParameter("tagname");
                feed = data.getQueryParameter("feed");
                unread = data.getQueryParameter("unread") != null;
                path = data.getPath();
            }
        }

        if (feed == null || feed.equals("")) {
            bookmarkFrag = new BrowseBookmarksFragment();
        } else {
            bookmarkFrag = new BrowseBookmarkFeedFragment();
        }

        t.add(R.id.listcontent, bookmarkFrag);
    } else {
        if (savedInstanceState != null) {
            tagname = savedInstanceState.getString(STATE_TAGNAME);
            unread = savedInstanceState.getBoolean(STATE_UNREAD);
            query = savedInstanceState.getString(STATE_QUERY);
            path = savedInstanceState.getString(STATE_PATH);
            feed = savedInstanceState.getString(STATE_FEED);
        }

        bookmarkFrag = fm.findFragmentById(R.id.listcontent);
    }

    if (feed == null || feed.equals("")) {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, app.getUsername(), tagname, unread);
        } else {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, unread ? "unread" : null);
        }

        ((BrowseBookmarksFragment) bookmarkFrag).refresh();
    } else {
        if (query == null || query.equals("")) {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, feed);
        } else {
            ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), query, feed);
        }
    }

    BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent);

    if (tagFrag != null) {
        tagFrag.setAccount(app.getUsername());
    }

    if (path != null && path.contains("tags")) {
        t.hide(fm.findFragmentById(R.id.maincontent));
        findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
    } else {
        if (tagFrag != null) {
            t.hide(tagFrag);
        }
    }

    Fragment addFrag = fm.findFragmentById(R.id.addcontent);
    if (addFrag != null) {
        t.hide(addFrag);
    }

    t.commit();
}

From source file:com.synox.android.ui.activity.ShareActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Verify the action and get the query
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        Log_OC.w(TAG, "Ignored Intent requesting to query for " + query);

    } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
        Uri data = intent.getData();/* w w w . j  a  v  a  2 s.  c  o  m*/
        String dataString = intent.getDataString();
        String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);
        doShareWith(shareWith, UsersAndGroupsSearchProvider.DATA_GROUP.equals(data.getAuthority()));

    } else {
        Log_OC.wtf(TAG, "Unexpected intent " + intent.toString());
    }
}

From source file:com.example.chu.googleplaylibrary.ui.MusicPlayerActivity.java

protected void initializeFromParams(Bundle savedInstanceState, Intent intent) {
    String mediaId = null;/*from w  w w .j av a 2  s .co  m*/
    // check if we were started from a "Play XYZ" voice search. If so, we save the extras
    // (which contain the query details) in a parameter, so we can reuse it later, when the
    // MediaSession is connected.
    if (intent.getAction() != null
            && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
        mVoiceSearchParams = intent.getExtras();
        LogHelper.d(TAG, "Starting from voice search query=",
                mVoiceSearchParams.getString(SearchManager.QUERY));
    } else {
        if (savedInstanceState != null) {
            // If there is a saved media ID, use it
            mediaId = savedInstanceState.getString(SAVED_MEDIA_ID);
        }
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected() " + this.hashCode());
    switch (item.getItemId()) {
    case android.R.id.home:
        final Intent upIntent = NavUtils.getParentActivityIntent(this);
        upIntent.putExtra(SearchManager.QUERY, this.originalQuery);
        NavUtils.navigateUpTo(this, upIntent);
        return true;
    }/*  ww  w.j av  a2 s  .c  o  m*/
    return super.onOptionsItemSelected(item);
}

From source file:org.tlhInganHol.android.klingonassistant.EntryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // TTS://w w w  .  j  a va2s. c  om
    // Initialize text-to-speech. This is an asynchronous operation.
    // The OnInitListener (second argument) is called after initialization completes.
    // Log.d(TAG, "Initialising TTS");
    mTts = new TextToSpeech(this, this, // TextToSpeech.OnInitListener
            "org.tlhInganHol.android.klingonttsengine"); // Requires API 14.

    setDrawerContentView(R.layout.entry);
    Resources resources = getResources();

    JellyBeanSpanFixTextView entryTitle = (JellyBeanSpanFixTextView) findViewById(R.id.entry_title);
    JellyBeanSpanFixTextView entryText = (JellyBeanSpanFixTextView) findViewById(R.id.definition);

    // TODO: Save and restore bundle state to preserve links.

    Uri uri = getIntent().getData();
    // Log.d(TAG, "EntryActivity - uri: " + uri.toString());
    // TODO: Disable the "About" menu item if this is the "About" entry.
    mParentQuery = getIntent().getStringExtra(SearchManager.QUERY);

    // Retrieve the entry's data.
    // Note: managedQuery is deprecated since API 11.
    Cursor cursor = managedQuery(uri, KlingonContentDatabase.ALL_KEYS, null, null, null);
    KlingonContentProvider.Entry entry = new KlingonContentProvider.Entry(cursor, getBaseContext());

    // Handle alternative spellings here.
    if (entry.isAlternativeSpelling()) {
        // TODO: Immediate redirect to query in entry.getDefinition();
    }

    // Get the shared preferences.
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // Set the entry's name (along with info like "slang", formatted in HTML).
    entryTitle.invalidate();
    boolean useKlingonFont = sharedPrefs.getBoolean(Preferences.KEY_KLINGON_FONT_CHECKBOX_PREFERENCE,
            /* default */false);
    Typeface klingonTypeface = KlingonAssistant.getKlingonFontTypeface(getBaseContext());
    if (useKlingonFont) {
        // Preference is set to display this in {pIqaD}!
        entryTitle.setTypeface(klingonTypeface);
        entryTitle.setText(entry.getEntryNameInKlingonFont());
    } else {
        // Boring transcription based on English (Latin) alphabet.
        entryTitle.setText(Html.fromHtml(entry.getFormattedEntryName(/* isHtml */true)));
    }
    mEntryName = entry.getEntryName();

    // Set the colour for the entry name depending on its part of speech.
    boolean useColours = sharedPrefs.getBoolean(Preferences.KEY_USE_COLOURS_CHECKBOX_PREFERENCE,
            /* default */true);
    if (useColours) {
        entryTitle.setTextColor(entry.getTextColor());
    }

    // Create the expanded definition.
    String pos = entry.getFormattedPartOfSpeech(/* isHtml */false);
    String expandedDefinition = pos + entry.getDefinition();

    // Show the German definition.
    String definition_DE = "";
    boolean displayGermanEntry = entry.shouldDisplayGerman();
    int germanDefinitionStart = -1;
    String germanDefinitionHeader = "\n" + resources.getString(R.string.label_german) + ": ";
    if (displayGermanEntry) {
        germanDefinitionStart = expandedDefinition.length();
        definition_DE = entry.getDefinition_DE();
        expandedDefinition += germanDefinitionHeader + definition_DE;
    }

    // Set the share intent.
    setShareEntryIntent(entry);

    // Show the basic notes.
    String notes = entry.getNotes();
    if (!notes.equals("")) {
        expandedDefinition += "\n\n" + notes;
    }

    // If this entry is hypothetical or extended canon, display warnings.
    if (entry.isHypothetical() || entry.isExtendedCanon()) {
        expandedDefinition += "\n\n";
        if (entry.isHypothetical()) {
            expandedDefinition += resources.getString(R.string.warning_hypothetical);
        }
        if (entry.isExtendedCanon()) {
            expandedDefinition += resources.getString(R.string.warning_extended_canon);
        }
    }

    // Show synonyms, antonyms, and related entries.
    String synonyms = entry.getSynonyms();
    String antonyms = entry.getAntonyms();
    String seeAlso = entry.getSeeAlso();
    if (!synonyms.equals("")) {
        expandedDefinition += "\n\n" + resources.getString(R.string.label_synonyms) + ": " + synonyms;
    }
    if (!antonyms.equals("")) {
        expandedDefinition += "\n\n" + resources.getString(R.string.label_antonyms) + ": " + antonyms;
    }
    if (!seeAlso.equals("")) {
        expandedDefinition += "\n\n" + resources.getString(R.string.label_see_also) + ": " + seeAlso;
    }

    // Display components if that field is not empty, unless we are showing an analysis link, in
    // which case we want to hide the components.
    boolean showAnalysis = entry.isSentence() || entry.isDerivative();
    String components = entry.getComponents();
    if (!components.equals("")) {
        // Treat the components column of inherent plurals and their
        // singulars differently than for other entries.
        if (entry.isInherentPlural()) {
            expandedDefinition += "\n\n"
                    + String.format(resources.getString(R.string.info_inherent_plural), components);
        } else if (entry.isSingularFormOfInherentPlural()) {
            expandedDefinition += "\n\n"
                    + String.format(resources.getString(R.string.info_singular_form), components);
        } else if (!showAnalysis) {
            // This is just a regular list of components.
            expandedDefinition += "\n\n" + resources.getString(R.string.label_components) + ": " + components;
        }
    }

    // Display plural information.
    if (!entry.isPlural() && !entry.isInherentPlural() && !entry.isPlural()) {
        if (entry.isBeingCapableOfLanguage()) {
            expandedDefinition += "\n\n" + resources.getString(R.string.info_being);
        } else if (entry.isBodyPart()) {
            expandedDefinition += "\n\n" + resources.getString(R.string.info_body);
        }
    }

    // If the entry is a useful phrase, link back to its category.
    if (entry.isSentence()) {
        String sentenceType = entry.getSentenceType();
        if (!sentenceType.equals("")) {
            // Put the query as a placeholder for the actual category.
            expandedDefinition += "\n\n" + resources.getString(R.string.label_category) + ": {"
                    + entry.getSentenceTypeQuery() + "}";
        }
    }

    // If the entry is a sentence, make a link to analyse its components.
    if (showAnalysis) {
        String analysisQuery = entry.getEntryName();
        if (!components.equals("")) {
            // Strip the brackets around each component so they won't be processed.
            analysisQuery += ":" + entry.getPartOfSpeech();
            int homophoneNumber = entry.getHomophoneNumber();
            if (homophoneNumber != -1) {
                analysisQuery += ":" + homophoneNumber;
            }
            analysisQuery += KlingonContentProvider.Entry.COMPONENTS_MARKER + components.replaceAll("[{}]", "");
        }
        expandedDefinition += "\n\n" + resources.getString(R.string.label_analyze) + ": {" + analysisQuery
                + "}";
    }

    // Show the examples.
    String examples = entry.getExamples();
    if (!examples.equals("")) {
        expandedDefinition += "\n\n" + resources.getString(R.string.label_examples) + ": " + examples;
    }

    // Show the source.
    String source = entry.getSource();
    if (!source.equals("")) {
        expandedDefinition += "\n\n" + resources.getString(R.string.label_sources) + ": " + source;
    }

    // If this is a verb (but not a prefix or suffix), show the transitivity information.
    String transitivity = "";
    if (entry.isVerb()
            && sharedPrefs.getBoolean(Preferences.KEY_SHOW_TRANSITIVITY_CHECKBOX_PREFERENCE, /* default */
                    true)) {
        // This is a verb and show transitivity preference is set to true.
        transitivity = entry.getTransitivityString();
    }
    int transitivityStart = -1;
    String transitivityHeader = "\n\n" + resources.getString(R.string.label_transitivity) + ": ";
    boolean showTransitivityInformation = !transitivity.equals("");
    if (showTransitivityInformation) {
        transitivityStart = expandedDefinition.length();
        expandedDefinition += transitivityHeader + transitivity;
    }

    // Show the hidden notes.
    String hiddenNotes = "";
    if (sharedPrefs.getBoolean(Preferences.KEY_SHOW_ADDITIONAL_INFORMATION_CHECKBOX_PREFERENCE, /* default */
            true)) {
        // Show additional information preference set to true.
        hiddenNotes = entry.getHiddenNotes();
    }
    int hiddenNotesStart = -1;
    String hiddenNotesHeader = "\n\n" + resources.getString(R.string.label_additional_information) + ": ";
    if (!hiddenNotes.equals("")) {
        hiddenNotesStart = expandedDefinition.length();
        expandedDefinition += hiddenNotesHeader + hiddenNotes;
    }

    // Format the expanded definition, including linkifying the links to other entries.
    float smallTextScale = (float) 0.8;
    SpannableStringBuilder ssb = new SpannableStringBuilder(expandedDefinition);
    int intermediateFlags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_INTERMEDIATE;
    int finalFlags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    if (!pos.equals("")) {
        // Italicise the part of speech.
        ssb.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, pos.length(), finalFlags);
    }
    if (displayGermanEntry) {
        // Reduce the size of the German definition.
        ssb.setSpan(new RelativeSizeSpan(smallTextScale), germanDefinitionStart,
                germanDefinitionStart + germanDefinitionHeader.length() + definition_DE.length(), finalFlags);
    }
    if (showTransitivityInformation) {
        // Reduce the size of the transitivity information.
        ssb.setSpan(new RelativeSizeSpan(smallTextScale), transitivityStart,
                transitivityStart + transitivityHeader.length() + transitivity.length(), finalFlags);
    }
    if (!hiddenNotes.equals("")) {
        // Reduce the size of the hidden notes.
        ssb.setSpan(new RelativeSizeSpan(smallTextScale), hiddenNotesStart,
                hiddenNotesStart + hiddenNotesHeader.length() + hiddenNotes.length(), finalFlags);
    }
    Matcher m = KlingonContentProvider.Entry.ENTRY_PATTERN.matcher(expandedDefinition);
    while (m.find()) {

        // Strip the brackets {} to get the query.
        String query = expandedDefinition.substring(m.start() + 1, m.end() - 1);
        LookupClickableSpan viewLauncher = new LookupClickableSpan(query);

        // Process the linked entry information.
        KlingonContentProvider.Entry linkedEntry = new KlingonContentProvider.Entry(query, getBaseContext());
        // Log.d(TAG, "linkedEntry.getEntryName() = " + linkedEntry.getEntryName());

        // Delete the brackets and metadata parts of the string (which includes analysis components).
        ssb.delete(m.start() + 1 + linkedEntry.getEntryName().length(), m.end());
        ssb.delete(m.start(), m.start() + 1);
        int end = m.start() + linkedEntry.getEntryName().length();

        // Insert link to the category for a useful phrase.
        if (entry.isSentence() && !entry.getSentenceType().equals("")
                && linkedEntry.getEntryName().equals("*")) {
            // Delete the "*" placeholder.
            ssb.delete(m.start(), m.start() + 1);

            // Insert the category name.
            ssb.insert(m.start(), entry.getSentenceType());
            end += entry.getSentenceType().length() - 1;
        }

        // Set the font and link.
        // TODO: Source should link to description of the source.
        // This is true if this entry doesn't launch an EntryActivity.
        boolean disableEntryLink = linkedEntry.doNotLink() || linkedEntry.isSource() || linkedEntry.isURL();
        // The last span set on a range must have finalFlags.
        int maybeFinalFlags = disableEntryLink ? finalFlags : intermediateFlags;
        if (linkedEntry.isSource()) {
            // Names of sources are in italics.
            ssb.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), m.start(), end, maybeFinalFlags);
        } else if (linkedEntry.isURL()) {
            // Linkify URL if there is one.
            String url = linkedEntry.getURL();
            if (!url.equals("")) {
                ssb.setSpan(new URLSpan(url), m.start(), end, maybeFinalFlags);
            }
        } else if (useKlingonFont) {
            // Display the text using the Klingon font. Categories (which have an entry of "*") must
            // be handled specially.
            String klingonEntryName = !linkedEntry.getEntryName().equals("*")
                    ? linkedEntry.getEntryNameInKlingonFont()
                    : KlingonContentProvider.convertStringToKlingonFont(entry.getSentenceType());
            ssb.delete(m.start(), end);
            ssb.insert(m.start(), klingonEntryName);
            end = m.start() + klingonEntryName.length();
            ssb.setSpan(new KlingonTypefaceSpan("", klingonTypeface), m.start(), end, maybeFinalFlags);
        } else {
            // Klingon is in bold serif.
            ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), m.start(), end, intermediateFlags);
            ssb.setSpan(new TypefaceSpan("serif"), m.start(), end, maybeFinalFlags);
        }
        // If linked entry is hypothetical or extended canon, insert a "?" in front.
        if (linkedEntry.isHypothetical() || linkedEntry.isExtendedCanon()) {
            ssb.insert(m.start(), "?");
            ssb.setSpan(new RelativeSizeSpan(smallTextScale), m.start(), m.start() + 1, intermediateFlags);
            ssb.setSpan(new SuperscriptSpan(), m.start(), m.start() + 1, maybeFinalFlags);
            end++;
        }
        // Only apply colours to verbs, nouns, and affixes (exclude BLUE and WHITE).
        if (!disableEntryLink) {
            // Link to view launcher.
            ssb.setSpan(viewLauncher, m.start(), end, useColours ? intermediateFlags : finalFlags);
        }
        // Set the colour last, so it's not overridden by other spans.
        if (useColours) {
            ssb.setSpan(new ForegroundColorSpan(linkedEntry.getTextColor()), m.start(), end, finalFlags);
        }
        String linkedPos = linkedEntry.getBracketedPartOfSpeech(/* isHtml */false);
        if (!linkedPos.equals("") && linkedPos.length() > 1) {
            ssb.insert(end, linkedPos);

            int rightBracketLoc = linkedPos.indexOf(")");
            if (rightBracketLoc != -1) {
                // linkedPos is always of the form " (pos)[ (def'n N)]", we want to italicise
                // the "pos" part only.
                ssb.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), end + 2, end + rightBracketLoc,
                        finalFlags);
            }
        }

        // Rinse and repeat.
        expandedDefinition = ssb.toString();
        m = KlingonContentProvider.Entry.ENTRY_PATTERN.matcher(expandedDefinition);
    }

    // Display the entry name and definition.
    entryText.invalidate();
    entryText.setText(ssb);
    entryText.setMovementMethod(LinkMovementMethod.getInstance());
}