Search experience improvement for large screen
- Support fragment and direct link in SearchResultTrampoline - Start activity for SI case and start deep link trampoline for others - Disable menu highlight whenever the search bar is clicked - Don't overwrite SettingsApplication's homepage activity in SliceDeepLinkHomepageActivity - Scroll to highlighted menu entry after homepage is loaded to prevent UI overlapping Bug: 201724410 Test: manual, robotest build pass Change-Id: I5115d17d829e85036000da2e80f0e5b0598c733f
This commit is contained in:
@@ -255,7 +255,8 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
// Should happen before any call to getIntent()
|
// Should happen before any call to getIntent()
|
||||||
getMetaData();
|
getMetaData();
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
if (launchHomepageForTwoPaneDeepLink(intent)) {
|
if (shouldShowTwoPaneDeepLink(intent)) {
|
||||||
|
launchHomepageForTwoPaneDeepLink(intent);
|
||||||
finishAndRemoveTask();
|
finishAndRemoveTask();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -368,16 +369,13 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
|
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the Activity is started by a deep link intent for large screen devices. */
|
/**
|
||||||
private boolean launchHomepageForTwoPaneDeepLink(Intent intent) {
|
* Returns the deep link trampoline intent for large screen devices.
|
||||||
if (!shouldShowTwoPaneDeepLink(intent)) {
|
*/
|
||||||
return false;
|
public static Intent getTrampolineIntent(Intent intent, String highlightMenuKey) {
|
||||||
}
|
|
||||||
|
|
||||||
final Intent detailIntent = new Intent(intent);
|
final Intent detailIntent = new Intent(intent);
|
||||||
// It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
|
// It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
|
||||||
final Intent trampolineIntent = new Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY);
|
final Intent trampolineIntent = new Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY);
|
||||||
|
|
||||||
trampolineIntent.replaceExtras(detailIntent);
|
trampolineIntent.replaceExtras(detailIntent);
|
||||||
|
|
||||||
// Relay detail intent data to prevent failure of Intent#ParseUri.
|
// Relay detail intent data to prevent failure of Intent#ParseUri.
|
||||||
@@ -391,22 +389,27 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
|
trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
|
||||||
detailIntent.toUri(Intent.URI_INTENT_SCHEME));
|
detailIntent.toUri(Intent.URI_INTENT_SCHEME));
|
||||||
|
|
||||||
if (detailIntent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
|
trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY,
|
||||||
trampolineIntent.setClass(this, SliceDeepLinkHomepageActivity.class);
|
highlightMenuKey);
|
||||||
|
trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
|
return trampolineIntent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void launchHomepageForTwoPaneDeepLink(Intent intent) {
|
||||||
|
final Intent trampolineIntent;
|
||||||
|
if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
|
||||||
// Get menu key for slice deep link case.
|
// Get menu key for slice deep link case.
|
||||||
final String highlightMenuKey = detailIntent.getStringExtra(
|
final String highlightMenuKey = intent.getStringExtra(
|
||||||
EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY);
|
EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY);
|
||||||
if (!TextUtils.isEmpty(highlightMenuKey)) {
|
if (!TextUtils.isEmpty(highlightMenuKey)) {
|
||||||
mHighlightMenuKey = highlightMenuKey;
|
mHighlightMenuKey = highlightMenuKey;
|
||||||
}
|
}
|
||||||
|
trampolineIntent = getTrampolineIntent(intent, mHighlightMenuKey);
|
||||||
|
trampolineIntent.setClass(this, SliceDeepLinkHomepageActivity.class);
|
||||||
|
} else {
|
||||||
|
trampolineIntent = getTrampolineIntent(intent, mHighlightMenuKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY,
|
|
||||||
mHighlightMenuKey);
|
|
||||||
trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
|
||||||
startActivity(trampolineIntent);
|
startActivity(trampolineIntent);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldShowTwoPaneDeepLink(Intent intent) {
|
private boolean shouldShowTwoPaneDeepLink(Intent intent) {
|
||||||
|
@@ -27,6 +27,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.ArraySet;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -54,6 +55,7 @@ import com.android.settings.overlay.FeatureFactory;
|
|||||||
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/** Settings homepage activity */
|
/** Settings homepage activity */
|
||||||
public class SettingsHomepageActivity extends FragmentActivity implements
|
public class SettingsHomepageActivity extends FragmentActivity implements
|
||||||
@@ -79,10 +81,27 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
private View mHomepageView;
|
private View mHomepageView;
|
||||||
private View mSuggestionView;
|
private View mSuggestionView;
|
||||||
private CategoryMixin mCategoryMixin;
|
private CategoryMixin mCategoryMixin;
|
||||||
|
private Set<HomepageLoadedListener> mLoadedListeners;
|
||||||
|
|
||||||
@Override
|
/** A listener receiving homepage loaded events. */
|
||||||
public CategoryMixin getCategoryMixin() {
|
public interface HomepageLoadedListener {
|
||||||
return mCategoryMixin;
|
/** Called when the homepage is loaded. */
|
||||||
|
void onHomepageLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to register a {@link HomepageLoadedListener}. If homepage is already loaded, the
|
||||||
|
* listener will not be notified.
|
||||||
|
*
|
||||||
|
* @return Whether the listener should be registered.
|
||||||
|
*/
|
||||||
|
public boolean registerHomepageLoadedListenerIfNeeded(HomepageLoadedListener listener) {
|
||||||
|
if (mHomepageView == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
mLoadedListeners.add(listener);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,17 +116,25 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
|
mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
|
||||||
mHomepageView.setVisibility(View.VISIBLE);
|
mHomepageView.setVisibility(View.VISIBLE);
|
||||||
mHomepageView = null;
|
mHomepageView = null;
|
||||||
|
mLoadedListeners.forEach(listener -> listener.onHomepageLoaded());
|
||||||
|
mLoadedListeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CategoryMixin getCategoryMixin() {
|
||||||
|
return mCategoryMixin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
((SettingsApplication) getApplication()).setHomeActivity(this);
|
setHomeActivity();
|
||||||
setContentView(R.layout.settings_homepage_container);
|
setContentView(R.layout.settings_homepage_container);
|
||||||
|
|
||||||
final View appBar = findViewById(R.id.app_bar_container);
|
final View appBar = findViewById(R.id.app_bar_container);
|
||||||
appBar.setMinimumHeight(getSearchBoxHeight());
|
appBar.setMinimumHeight(getSearchBoxHeight());
|
||||||
initHomepageContainer();
|
initHomepageContainer();
|
||||||
|
mLoadedListeners = new ArraySet<>();
|
||||||
|
|
||||||
final Toolbar toolbar = findViewById(R.id.search_action_bar);
|
final Toolbar toolbar = findViewById(R.id.search_action_bar);
|
||||||
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
||||||
@@ -158,6 +185,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
launchDeepLinkIntentToRight();
|
launchDeepLinkIntentToRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setHomeActivity() {
|
||||||
|
((SettingsApplication) getApplication()).setHomeActivity(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void showSuggestionFragment() {
|
private void showSuggestionFragment() {
|
||||||
final Class<? extends Fragment> fragment = FeatureFactory.getFactory(this)
|
final Class<? extends Fragment> fragment = FeatureFactory.getFactory(this)
|
||||||
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
|
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
|
||||||
|
@@ -20,6 +20,11 @@ import android.content.ComponentName;
|
|||||||
|
|
||||||
/** Activity for Slices to launch Settings deep link page */
|
/** Activity for Slices to launch Settings deep link page */
|
||||||
public class SliceDeepLinkHomepageActivity extends SettingsHomepageActivity {
|
public class SliceDeepLinkHomepageActivity extends SettingsHomepageActivity {
|
||||||
|
@Override
|
||||||
|
protected void setHomeActivity() {
|
||||||
|
// do not overwrite homepage activity in SettingsApplication
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ComponentName getDeepLinkComponent() {
|
protected ComponentName getDeepLinkComponent() {
|
||||||
return new ComponentName(getApplicationContext(), getClass());
|
return new ComponentName(getApplicationContext(), getClass());
|
||||||
|
@@ -101,7 +101,7 @@ public class TopLevelSettings extends DashboardFragment implements
|
|||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
// Register SplitPairRule for SubSettings.
|
// Register SplitPairRule for SubSettings.
|
||||||
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(getContext(),
|
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(getContext(),
|
||||||
true /* clearTop*/);
|
true /* clearTop */);
|
||||||
|
|
||||||
setHighlightPreferenceKey(preference.getKey());
|
setHighlightPreferenceKey(preference.getKey());
|
||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
@@ -184,6 +184,15 @@ public class TopLevelSettings extends DashboardFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Disable highlight on the menu entry */
|
||||||
|
public void disableMenuHighlight() {
|
||||||
|
if (mTopLevelAdapter == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHighlightedPreferenceKey = null;
|
||||||
|
mTopLevelAdapter.highlightPreference(mHighlightedPreferenceKey, /* scrollNeeded= */ false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldForceRoundedIcon() {
|
protected boolean shouldForceRoundedIcon() {
|
||||||
return getContext().getResources()
|
return getContext().getResources()
|
||||||
@@ -202,7 +211,8 @@ public class TopLevelSettings extends DashboardFragment implements
|
|||||||
|
|
||||||
Log.d(TAG, "onCreateAdapter, pref key: " + mHighlightedPreferenceKey);
|
Log.d(TAG, "onCreateAdapter, pref key: " + mHighlightedPreferenceKey);
|
||||||
mTopLevelAdapter = new HighlightableTopLevelPreferenceAdapter(
|
mTopLevelAdapter = new HighlightableTopLevelPreferenceAdapter(
|
||||||
getActivity(), preferenceScreen, getListView(), mHighlightedPreferenceKey);
|
(SettingsHomepageActivity) getActivity(), preferenceScreen, getListView(),
|
||||||
|
mHighlightedPreferenceKey);
|
||||||
return mTopLevelAdapter;
|
return mTopLevelAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.search;
|
|||||||
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -30,8 +29,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
|
import com.android.settings.homepage.TopLevelSettings;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.search.SearchIndexableResources;
|
import com.android.settingslib.search.SearchIndexableResources;
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ public interface SearchFeatureProvider {
|
|||||||
/**
|
/**
|
||||||
* Initializes the search toolbar.
|
* Initializes the search toolbar.
|
||||||
*/
|
*/
|
||||||
default void initSearchToolbar(Activity activity, Toolbar toolbar, int pageId) {
|
default void initSearchToolbar(FragmentActivity activity, Toolbar toolbar, int pageId) {
|
||||||
if (activity == null || toolbar == null) {
|
if (activity == null || toolbar == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -91,7 +94,8 @@ public interface SearchFeatureProvider {
|
|||||||
|
|
||||||
toolbar.setOnClickListener(tb -> {
|
toolbar.setOnClickListener(tb -> {
|
||||||
final Context context = activity.getApplicationContext();
|
final Context context = activity.getApplicationContext();
|
||||||
final Intent intent = buildSearchIntent(context, pageId);
|
final Intent intent = buildSearchIntent(context, pageId)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
|
||||||
if (activity.getPackageManager().queryIntentActivities(intent,
|
if (activity.getPackageManager().queryIntentActivities(intent,
|
||||||
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
|
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
|
||||||
@@ -103,8 +107,19 @@ public interface SearchFeatureProvider {
|
|||||||
|
|
||||||
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
||||||
.logSettingsTileClick(KEY_HOMEPAGE_SEARCH_BAR, pageId);
|
.logSettingsTileClick(KEY_HOMEPAGE_SEARCH_BAR, pageId);
|
||||||
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
|
|
||||||
|
if (ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||||
|
final TopLevelSettings fragment = (TopLevelSettings) activity
|
||||||
|
.getSupportFragmentManager().findFragmentById(R.id.main_content);
|
||||||
|
if (fragment != null) {
|
||||||
|
fragment.disableMenuHighlight();
|
||||||
|
}
|
||||||
|
activity.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity)
|
||||||
|
.toBundle();
|
||||||
activity.startActivity(intent, bundle);
|
activity.startActivity(intent, bundle);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,52 +20,102 @@ import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENT
|
|||||||
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB;
|
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SubSettings;
|
import com.android.settings.SubSettings;
|
||||||
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
||||||
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trampoline activity that launches setting result page.
|
* A trampoline activity that launches setting result page.
|
||||||
*/
|
*/
|
||||||
public class SearchResultTrampoline extends Activity {
|
public class SearchResultTrampoline extends Activity {
|
||||||
|
|
||||||
|
private static final String TAG = "SearchResultTrampoline";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final ComponentName callingActivity = getCallingActivity();
|
||||||
// First make sure caller has privilege to launch a search result page.
|
// First make sure caller has privilege to launch a search result page.
|
||||||
FeatureFactory.getFactory(this)
|
FeatureFactory.getFactory(this)
|
||||||
.getSearchFeatureProvider()
|
.getSearchFeatureProvider()
|
||||||
.verifyLaunchSearchResultPageCaller(this, getCallingActivity());
|
.verifyLaunchSearchResultPageCaller(this, callingActivity);
|
||||||
// Didn't crash, proceed and launch the result as a subsetting.
|
// Didn't crash, proceed and launch the result as a subsetting.
|
||||||
final Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
final String highlightMenuKey = intent.getStringExtra(
|
||||||
|
Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY);
|
||||||
|
|
||||||
|
final String fragment = intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT);
|
||||||
|
if (!TextUtils.isEmpty(fragment)) {
|
||||||
// Hack to take EXTRA_FRAGMENT_ARG_KEY from intent and set into
|
// Hack to take EXTRA_FRAGMENT_ARG_KEY from intent and set into
|
||||||
// EXTRA_SHOW_FRAGMENT_ARGUMENTS. This is necessary because intent could be from external
|
// EXTRA_SHOW_FRAGMENT_ARGUMENTS. This is necessary because intent could be from
|
||||||
// caller and args may not persisted.
|
// external caller and args may not persisted.
|
||||||
final String settingKey = intent.getStringExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
|
final String settingKey = intent.getStringExtra(
|
||||||
|
SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
|
||||||
final int tab = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TAB, 0);
|
final int tab = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TAB, 0);
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, settingKey);
|
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, settingKey);
|
||||||
args.putInt(EXTRA_SHOW_FRAGMENT_TAB, tab);
|
args.putInt(EXTRA_SHOW_FRAGMENT_TAB, tab);
|
||||||
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
|
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
|
||||||
|
|
||||||
// Register SplirPairRule for SubSettings, set clearTop false to prevent unexpected back
|
|
||||||
// navigation behavior.
|
|
||||||
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(this /* context */,
|
|
||||||
false /* clearTop*/);
|
|
||||||
|
|
||||||
// Reroute request to SubSetting.
|
// Reroute request to SubSetting.
|
||||||
intent.setClass(this /* context */, SubSettings.class)
|
intent.setClass(this /* context */, SubSettings.class);
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
} else {
|
||||||
|
// Direct link case
|
||||||
|
final String intentUriString = intent.getStringExtra(
|
||||||
|
Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI);
|
||||||
|
if (TextUtils.isEmpty(intentUriString)) {
|
||||||
|
Log.e(TAG, "No EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI for deep link");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
intent = Intent.parseUri(intentUriString, Intent.URI_INTENT_SCHEME);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
Log.e(TAG, "Failed to parse deep link intent: " + e);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
|
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else if (isFromSettingsIntelligence(callingActivity)) {
|
||||||
|
// Register SplitPairRule for SubSettings, set clearTop false to prevent unexpected back
|
||||||
|
// navigation behavior.
|
||||||
|
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(this,
|
||||||
|
false /* clearTop */);
|
||||||
|
// TODO: pass menu key to homepage
|
||||||
|
intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
// Two-pane case
|
||||||
|
intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(SettingsActivity.getTrampolineIntent(intent, highlightMenuKey));
|
||||||
|
}
|
||||||
|
|
||||||
// Done.
|
// Done.
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isFromSettingsIntelligence(ComponentName callingActivity) {
|
||||||
|
return callingActivity != null && TextUtils.equals(
|
||||||
|
callingActivity.getPackageName(),
|
||||||
|
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
||||||
|
.getSettingsIntelligencePkgName(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -365,7 +365,6 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
|
|||||||
// The classname and intent information comes from the PreIndexData
|
// The classname and intent information comes from the PreIndexData
|
||||||
// This will be more clear when provider conversion is done at PreIndex time.
|
// This will be more clear when provider conversion is done at PreIndex time.
|
||||||
raw.className = bundle.getTargetClass().getName();
|
raw.className = bundle.getTargetClass().getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
rawList.addAll(providerRaws);
|
rawList.addAll(providerRaws);
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.widget;
|
package com.android.settings.widget;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -34,6 +33,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
|
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for highlighting top level preferences
|
* Adapter for highlighting top level preferences
|
||||||
@@ -54,7 +54,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
final int mIconColorHighlight;
|
final int mIconColorHighlight;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Activity mActivity;
|
private final SettingsHomepageActivity mHomepageActivity;
|
||||||
private final RecyclerView mRecyclerView;
|
private final RecyclerView mRecyclerView;
|
||||||
private final int mNormalBackgroundRes;
|
private final int mNormalBackgroundRes;
|
||||||
private String mHighlightKey;
|
private String mHighlightKey;
|
||||||
@@ -63,13 +63,13 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
private boolean mHighlightNeeded;
|
private boolean mHighlightNeeded;
|
||||||
private boolean mScrolled;
|
private boolean mScrolled;
|
||||||
|
|
||||||
public HighlightableTopLevelPreferenceAdapter(Activity activity,
|
public HighlightableTopLevelPreferenceAdapter(SettingsHomepageActivity homepageActivity,
|
||||||
PreferenceGroup preferenceGroup, RecyclerView recyclerView, String key) {
|
PreferenceGroup preferenceGroup, RecyclerView recyclerView, String key) {
|
||||||
super(preferenceGroup);
|
super(preferenceGroup);
|
||||||
mRecyclerView = recyclerView;
|
mRecyclerView = recyclerView;
|
||||||
mHighlightKey = key;
|
mHighlightKey = key;
|
||||||
mContext = preferenceGroup.getContext();
|
mContext = preferenceGroup.getContext();
|
||||||
mActivity = activity;
|
mHomepageActivity = homepageActivity;
|
||||||
final TypedValue outValue = new TypedValue();
|
final TypedValue outValue = new TypedValue();
|
||||||
mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
|
mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
|
||||||
outValue, true /* resolveRefs */);
|
outValue, true /* resolveRefs */);
|
||||||
@@ -115,7 +115,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
* A function can highlight a specific setting in recycler view.
|
* A function can highlight a specific setting in recycler view.
|
||||||
*/
|
*/
|
||||||
public void requestHighlight() {
|
public void requestHighlight() {
|
||||||
if (mRecyclerView == null || TextUtils.isEmpty(mHighlightKey)) {
|
if (mRecyclerView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +194,11 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mHomepageActivity.registerHomepageLoadedListenerIfNeeded(
|
||||||
|
() -> scrollToPositionIfNeeded(position))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only when the recyclerView is loaded, it can be scrolled
|
// Only when the recyclerView is loaded, it can be scrolled
|
||||||
final View view = mRecyclerView.getChildAt(position);
|
final View view = mRecyclerView.getChildAt(position);
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
@@ -236,6 +241,6 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHighlightNeeded() {
|
private boolean isHighlightNeeded() {
|
||||||
return ActivityEmbeddingUtils.isTwoPaneResolution(mActivity);
|
return ActivityEmbeddingUtils.isTwoPaneResolution(mHomepageActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.search;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -29,6 +28,8 @@ import android.net.Uri;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
@@ -46,13 +47,13 @@ import org.robolectric.shadows.ShadowPackageManager;
|
|||||||
public class SearchFeatureProviderImplTest {
|
public class SearchFeatureProviderImplTest {
|
||||||
|
|
||||||
private SearchFeatureProviderImpl mProvider;
|
private SearchFeatureProviderImpl mProvider;
|
||||||
private Activity mActivity;
|
private FragmentActivity mActivity;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory.setupForTest();
|
||||||
mActivity = Robolectric.setupActivity(Activity.class);
|
mActivity = Robolectric.setupActivity(FragmentActivity.class);
|
||||||
mProvider = new SearchFeatureProviderImpl();
|
mProvider = new SearchFeatureProviderImpl();
|
||||||
mPackageManager = Shadows.shadowOf(mActivity.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mActivity.getPackageManager());
|
||||||
Settings.Global.putInt(mActivity.getContentResolver(),
|
Settings.Global.putInt(mActivity.getContentResolver(),
|
||||||
|
Reference in New Issue
Block a user