Merge "Fix abnormal behavior on search page" into sc-v2-dev am: ee18babe99
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16284151 Change-Id: I19a8fb6310cc3399291fe38f6026d1b751390e24
This commit is contained in:
@@ -99,20 +99,26 @@ public class ActivityEmbeddingRulesController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
|
* Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
|
||||||
* {@link Settings} or {@link SettingsHomepageActivity}, we register split rule twice for
|
* {@link Settings} or {@link SettingsHomepageActivity} or
|
||||||
* two cases.
|
* {@link SliceDeepLinkHomepageActivity}, we register split rule for above cases.
|
||||||
*/
|
*/
|
||||||
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
||||||
ComponentName secondaryComponent,
|
ComponentName secondaryComponent,
|
||||||
String secondaryIntentAction,
|
String secondaryIntentAction,
|
||||||
|
boolean finishPrimaryWithSecondary,
|
||||||
|
boolean finishSecondaryWithPrimary,
|
||||||
boolean clearTop) {
|
boolean clearTop) {
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
context,
|
context,
|
||||||
getComponentName(context, Settings.class),
|
getComponentName(context, Settings.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -120,8 +126,8 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, DeepLinkHomepageActivity.class),
|
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -129,8 +135,8 @@ public class ActivityEmbeddingRulesController {
|
|||||||
getComponentName(context, SettingsHomepageActivity.class),
|
getComponentName(context, SettingsHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
finishPrimaryWithSecondary,
|
||||||
true /* finishSecondaryWithPrimary */,
|
finishSecondaryWithPrimary,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -138,6 +144,26 @@ public class ActivityEmbeddingRulesController {
|
|||||||
getComponentName(context, SliceDeepLinkHomepageActivity.class),
|
getComponentName(context, SliceDeepLinkHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
|
finishPrimaryWithSecondary,
|
||||||
|
finishSecondaryWithPrimary,
|
||||||
|
clearTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a new SplitPairRule for Settings home.
|
||||||
|
*/
|
||||||
|
public static void registerTwoPanePairRuleForSettingsHome(Context context,
|
||||||
|
ComponentName secondaryComponent,
|
||||||
|
String secondaryIntentAction,
|
||||||
|
boolean clearTop) {
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerTwoPanePairRuleForSettingsHome(
|
||||||
|
context,
|
||||||
|
secondaryComponent,
|
||||||
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
true /* finishPrimaryWithSecondary */,
|
||||||
true /* finishSecondaryWithPrimary */,
|
true /* finishSecondaryWithPrimary */,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -33,11 +34,14 @@ 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.ActivityEmbeddingRulesController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.search.SearchIndexableResources;
|
import com.android.settingslib.search.SearchIndexableResources;
|
||||||
|
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FeatureProvider for Settings Search
|
* FeatureProvider for Settings Search
|
||||||
*/
|
*/
|
||||||
@@ -60,6 +64,9 @@ public interface SearchFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
SearchIndexableResources getSearchIndexableResources();
|
SearchIndexableResources getSearchIndexableResources();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a package name of settings intelligence.
|
||||||
|
*/
|
||||||
default String getSettingsIntelligencePkgName(Context context) {
|
default String getSettingsIntelligencePkgName(Context context) {
|
||||||
return context.getString(R.string.config_settingsintelligence_package_name);
|
return context.getString(R.string.config_settingsintelligence_package_name);
|
||||||
}
|
}
|
||||||
@@ -90,16 +97,30 @@ public interface SearchFeatureProvider {
|
|||||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
navView.setBackground(null);
|
navView.setBackground(null);
|
||||||
|
|
||||||
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);
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
final List<ResolveInfo> resolveInfos =
|
||||||
if (activity.getPackageManager().queryIntentActivities(intent,
|
activity.getPackageManager().queryIntentActivities(intent,
|
||||||
PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
|
PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
if (resolveInfos.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final ComponentName searchComponentName = resolveInfos.get(0)
|
||||||
|
.getComponentInfo().getComponentName();
|
||||||
|
// Set a component name since activity embedding requires a component name for
|
||||||
|
// registering a rule.
|
||||||
|
intent.setComponent(searchComponentName);
|
||||||
|
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
|
||||||
|
context,
|
||||||
|
searchComponentName,
|
||||||
|
intent.getAction(),
|
||||||
|
false /* finishPrimaryWithSecondary */,
|
||||||
|
true /* finishSecondaryWithPrimary */,
|
||||||
|
false /* clearTop */);
|
||||||
|
|
||||||
|
toolbar.setOnClickListener(tb -> {
|
||||||
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
||||||
.indexSliceDataAsync(context);
|
.indexSliceDataAsync(context);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user