Merge "Send context object to FeatureFlagUtils."
This commit is contained in:
committed by
Android (Google) Code Review
commit
9767b45534
@@ -89,7 +89,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return FeatureFlagUtils.isEnabled(DEVICE_INFO_V2)
|
||||
return FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2)
|
||||
? R.xml.device_info_settings_v2 : R.xml.device_info_settings;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Activity activity, Fragment fragment, Lifecycle lifecycle) {
|
||||
if (FeatureFlagUtils.isEnabled(DEVICE_INFO_V2)) {
|
||||
if (FeatureFlagUtils.isEnabled(context, DEVICE_INFO_V2)) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
// Device name
|
||||
|
||||
|
@@ -67,7 +67,7 @@ public class Settings extends SettingsActivity {
|
||||
@Deprecated
|
||||
public static class DevelopmentSettingsActivity extends SettingsActivity {
|
||||
public static final boolean isEnabled() {
|
||||
return FeatureFlagUtils.isEnabled(DEV_OPTION_V1);
|
||||
return FeatureFlagUtils.isEnabled(null /* context */, DEV_OPTION_V1);
|
||||
}
|
||||
}
|
||||
public static class DevelopmentSettingsDashboardActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -21,7 +21,6 @@ import android.os.Bundle;
|
||||
import android.support.annotation.XmlRes;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.core.instrumentation.Instrumentable;
|
||||
|
@@ -73,7 +73,7 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
final ActivityManager am =
|
||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
boolean isLowRamDevice = am.isLowRamDevice();
|
||||
return !isLowRamDevice && !isV2Enabled();
|
||||
return !isLowRamDevice && !isV2Enabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +81,7 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
final ActivityManager am =
|
||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
boolean isLowRamDevice = am.isLowRamDevice();
|
||||
return !isLowRamDevice && isV2Enabled();
|
||||
return !isLowRamDevice && isV2Enabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,8 +91,8 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
"com.android.settings.intelligence.suggestions.SuggestionService");
|
||||
}
|
||||
|
||||
private static boolean isV2Enabled() {
|
||||
return FeatureFlagUtils.isEnabled(SUGGESTIONS_V2) || true;
|
||||
private static boolean isV2Enabled(Context context) {
|
||||
return FeatureFlagUtils.isEnabled(context, SUGGESTIONS_V2) || true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -29,7 +29,7 @@ public class FeatureFlagPreference extends SwitchPreference {
|
||||
mKey = key;
|
||||
setKey(key);
|
||||
setTitle(key);
|
||||
setCheckedInternal(FeatureFlagUtils.isEnabled(mKey));
|
||||
setCheckedInternal(FeatureFlagUtils.isEnabled(context, mKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -51,7 +51,7 @@ public class DeviceModelPreferenceController extends AbstractPreferenceControlle
|
||||
super.displayPreference(screen);
|
||||
final Preference pref = screen.findPreference(KEY_DEVICE_MODEL);
|
||||
if (pref != null) {
|
||||
if (FeatureFlagUtils.isEnabled(FeatureFlags.DEVICE_INFO_V2)) {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.DEVICE_INFO_V2)) {
|
||||
pref.setSummary(mContext.getResources().getString(R.string.model_summary,
|
||||
getDeviceModel()));
|
||||
} else {
|
||||
|
@@ -59,7 +59,7 @@ public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
|
||||
DeviceModelPreferenceController.getDeviceModel());
|
||||
|
||||
// Serial number
|
||||
if (FeatureFlagUtils.isEnabled(FeatureFlags.DEVICE_INFO_V2)) {
|
||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DEVICE_INFO_V2)) {
|
||||
setText(content, R.id.serial_number_label, R.id.serial_number_value, getSerialNumber());
|
||||
} else {
|
||||
content.findViewById(R.id.serial_number_label).setVisibility(View.GONE);
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.search;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -167,18 +168,18 @@ public interface SearchFeatureProvider {
|
||||
/**
|
||||
* Initializes the search toolbar.
|
||||
*/
|
||||
default void initSearchToolbar(Context context, Toolbar toolbar) {
|
||||
if (context == null || toolbar == null) {
|
||||
default void initSearchToolbar(Activity activity, Toolbar toolbar) {
|
||||
if (activity == null || toolbar == null) {
|
||||
return;
|
||||
}
|
||||
toolbar.setOnClickListener(tb -> {
|
||||
final Intent intent;
|
||||
if (FeatureFlagUtils.isEnabled(FeatureFlags.SEARCH_V2)) {
|
||||
if (FeatureFlagUtils.isEnabled(activity, FeatureFlags.SEARCH_V2)) {
|
||||
intent = new Intent("com.android.settings.action.SETTINGS_SEARCH");
|
||||
} else {
|
||||
intent = new Intent(context, SearchActivity.class);
|
||||
intent = new Intent(activity, SearchActivity.class);
|
||||
}
|
||||
context.startActivity(intent);
|
||||
activity.startActivityForResult(intent, 0 /* requestCode */);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user