/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.focus.activity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;

import org.mozilla.focus.utils.SafeIntent;
import org.mozilla.focus.utils.UrlUtils;

/**
 * Activity for receiving and processing an ACTION_PROCESS_TEXT intent.
 */
public class TextActionActivity extends Activity {
    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final SafeIntent intent = new SafeIntent(getIntent());

        final String searchText = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString();
        final String searchUrl = UrlUtils.createSearchUrl(this, searchText);

        final Intent searchIntent = new Intent(this, MainActivity.class);
        searchIntent.setAction(Intent.ACTION_VIEW);
        searchIntent.putExtra(MainActivity.EXTRA_TEXT_SELECTION, true);
        searchIntent.setData(Uri.parse(searchUrl));

        startActivity(searchIntent);

        finish();
    }
}

@@ -1012,25 +1012,43 @@
 nal 
-String searchText
+CharSequence searchTextCharSequence
  = i
@@ -1104,20 +1104,204 @@
 EXT)
-.toString();
+;%0A        final String searchText;%0A        if (searchTextCharSequence != null) %7B%0A            searchText = searchTextCharSequence.toString();%0A        %7D else %7B%0A            searchText = %22%22;%0A        %7D
 %0A   

Make TextActionActivity null-safe