Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 413eaa40 authored by Fan Zhang's avatar Fan Zhang
Browse files

Clean up search fragment loader lifecycle.

- Programatically create SearchView to make it always expand across
  entire action bar.
- Store current query text during screen rotation
- Restart loader when query text changes

Bug: 33354491
Test: RunSettingsRoboTests
Change-Id: I63838a38514569aac60c5d67ac52ac06a7acd5a3
parent 2425a528
Loading
Loading
Loading
Loading

res/menu/search_options_menu.xml

deleted100644 → 0
+0 −23
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/search"
        android:title="@string/search_menu"
        android:icon="@*android:drawable/ic_search_api_material"
        android:showAsAction="collapseActionView|ifRoom"
        android:actionViewClass="android.widget.SearchView"/>
</menu>
+2 −2
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ import android.view.View;
import android.view.ViewGroup;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SupportFeatureProvider;
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.SimpleItemAnimator;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+7 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
package com.android.settings.search2;

import android.app.Activity;
import android.widget.SearchView;
import android.content.Context;
import android.view.Menu;

/**
@@ -31,8 +31,14 @@ public interface SearchFeatureProvider {

    /**
     * Inserts the Menu items into Settings activity.
     *
     * @param menu Items will be inserted into this menu.
     * @param activity The activity that precedes SearchActivity.
     */
    void setUpSearchMenu(Menu menu, Activity activity);

    /**
     * Returns a new loader to search in index database.
     */
    DatabaseResultLoader getDatabaseSearchLoader(Context context, String query);
}
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import android.view.Menu;

import android.view.MenuItem;
import com.android.settings.R;
import com.android.settings.utils.AsyncLoader;

import java.util.List;

/**
 * FeatureProvider for the refactored search code.
@@ -60,4 +63,9 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {

        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    @Override
    public DatabaseResultLoader getDatabaseSearchLoader(Context context, String query) {
        return new DatabaseResultLoader(context, query);
    }
}
Loading