diff options
Diffstat (limited to 'src')
14 files changed, 217 insertions, 40 deletions
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java index c562faee1d..22453a3972 100644 --- a/src/com/android/settings/AllInOneTetherSettings.java +++ b/src/com/android/settings/AllInOneTetherSettings.java @@ -91,8 +91,12 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment private static final String KEY_DATA_SAVER_FOOTER = "disabled_on_data_saver" + DEDUP_POSTFIX; private static final String KEY_WIFI_TETHER_GROUP = "wifi_tether_settings_group"; - private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2; - private static final int EXPANDED_CHILD_COUNT_DEFAULT = 3; + @VisibleForTesting + static final int EXPANDED_CHILD_COUNT_DEFAULT = 3; + @VisibleForTesting + static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2; + @VisibleForTesting + static final int EXPANDED_CHILD_COUNT_WITHOUT_WIFI_CONFIG = 3; private static final String TAG = "AllInOneTetherSettings"; private boolean mUnavailable; @@ -120,7 +124,6 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment mUsbTethering = TetherEnabler.isUsbTethering(state); mWifiTethering = TetherEnabler.isWifiTethering(state); mWifiTetherGroup.setVisible(shouldShowWifiConfig()); - reConfigInitialExpandedChildCount(); }; private final BroadcastReceiver mTetherChangeReceiver = new BroadcastReceiver() { @@ -354,10 +357,6 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment mRestartWifiApAfterConfigChange = true; mTetherEnabler.stopTethering(TETHERING_WIFI); } - - if (controller instanceof WifiTetherSecurityPreferenceController) { - reConfigInitialExpandedChildCount(); - } } private SoftApConfiguration buildNewConfig() { @@ -384,15 +383,10 @@ public class AllInOneTetherSettings extends RestrictedDashboardFragment return mWifiTethering || (!mBluetoothTethering && !mUsbTethering); } - private void reConfigInitialExpandedChildCount() { - getPreferenceScreen().setInitialExpandedChildrenCount(getInitialExpandedChildCount()); - } - @Override public int getInitialExpandedChildCount() { if (!shouldShowWifiConfig()) { - // Expand all preferences in the screen. - return getPreferenceScreen().getPreferenceCount(); + return EXPANDED_CHILD_COUNT_WITHOUT_WIFI_CONFIG; } if (mSecurityPreferenceController == null) { diff --git a/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java index b37fdfb851..0550908f3f 100644 --- a/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java +++ b/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java @@ -19,7 +19,6 @@ package com.android.settings.accessibility; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.res.Resources; -import android.provider.SearchIndexableResource; import androidx.preference.Preference; @@ -31,7 +30,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.search.SearchIndexable; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; @SearchIndexable @@ -88,6 +86,11 @@ public final class AccessibilityControlTimeoutPreferenceFragment extends Dashboa return buildPreferenceControllers(context, getSettingsLifecycle()); } + @Override + public int getHelpResource() { + return R.string.help_url_timeout; + } + private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, Lifecycle lifecycle) { if (sControllers.size() == 0) { diff --git a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java index 394f50ab78..6c2b593c47 100644 --- a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java +++ b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java @@ -105,7 +105,7 @@ public class CaptionAppearanceFragment extends SettingsPreferenceFragment @Override public int getMetricsCategory() { - return SettingsEnums.ACCESSIBILITY_CAPTION_PROPERTIES; + return SettingsEnums.ACCESSIBILITY_CAPTION_APPEARANCE; } @Override diff --git a/src/com/android/settings/accessibility/CaptionMoreOptionsFragment.java b/src/com/android/settings/accessibility/CaptionMoreOptionsFragment.java index 8e5c003189..d3fd407436 100644 --- a/src/com/android/settings/accessibility/CaptionMoreOptionsFragment.java +++ b/src/com/android/settings/accessibility/CaptionMoreOptionsFragment.java @@ -44,7 +44,7 @@ public class CaptionMoreOptionsFragment extends SettingsPreferenceFragment @Override public int getMetricsCategory() { - return SettingsEnums.ACCESSIBILITY_CAPTION_PROPERTIES; + return SettingsEnums.ACCESSIBILITY_CAPTION_MORE_OPTIONS; } @Override diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java index 5e09b2a78c..6624457ad9 100644 --- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java @@ -64,12 +64,10 @@ public class ToggleAutoclickPreferenceFragment extends DashboardFragment * Resource ids from which autoclick preference summaries should be derived. The strings have * placeholder for integer delay value. */ - private static final int[] mAutoclickPreferenceSummaries = { - R.plurals.accessibilty_autoclick_preference_subtitle_extremely_short_delay, - R.plurals.accessibilty_autoclick_preference_subtitle_very_short_delay, + private static final int[] AUTOCLICK_PREFERENCE_SUMMARIES = { R.plurals.accessibilty_autoclick_preference_subtitle_short_delay, - R.plurals.accessibilty_autoclick_preference_subtitle_long_delay, - R.plurals.accessibilty_autoclick_preference_subtitle_very_long_delay + R.plurals.accessibilty_autoclick_preference_subtitle_medium_delay, + R.plurals.accessibilty_autoclick_preference_subtitle_long_delay }; /** @@ -86,7 +84,7 @@ public class ToggleAutoclickPreferenceFragment extends DashboardFragment // Only show integer when delay time is 1. final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f"; - return resources.getQuantityString(mAutoclickPreferenceSummaries[summaryIndex], + return resources.getQuantityString(AUTOCLICK_PREFERENCE_SUMMARIES[summaryIndex], quantity, String.format(decimalFormat, delaySecond)); } @@ -98,10 +96,10 @@ public class ToggleAutoclickPreferenceFragment extends DashboardFragment return 0; } if (delay >= MAX_AUTOCLICK_DELAY_MS) { - return mAutoclickPreferenceSummaries.length - 1; + return AUTOCLICK_PREFERENCE_SUMMARIES.length - 1; } int delayRange = MAX_AUTOCLICK_DELAY_MS - MIN_AUTOCLICK_DELAY_MS; - int rangeSize = (delayRange) / (mAutoclickPreferenceSummaries.length - 1); + int rangeSize = (delayRange) / (AUTOCLICK_PREFERENCE_SUMMARIES.length - 1); return (delay - MIN_AUTOCLICK_DELAY_MS) / rangeSize; } diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java index c0ad2ac235..833c9f181e 100644 --- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java @@ -114,6 +114,11 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere } @Override + public int getHelpResource() { + return R.string.help_url_color_inversion; + } + + @Override public void onSettingsClicked(ShortcutPreference preference) { super.onSettingsClicked(preference); showDialog(DialogEnums.EDIT_SHORTCUT); diff --git a/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java index 12393ad13f..cf0be20747 100644 --- a/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java +++ b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java @@ -19,6 +19,7 @@ package com.android.settings.applications.appinfo; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.icu.text.ListFormatter; import android.util.Log; @@ -28,15 +29,24 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settingslib.applications.PermissionsSummaryHelper; +import com.android.settingslib.core.lifecycle.LifecycleObserver; +import com.android.settingslib.core.lifecycle.events.OnStart; +import com.android.settingslib.core.lifecycle.events.OnStop; import java.util.ArrayList; import java.util.List; -public class AppPermissionPreferenceController extends AppInfoPreferenceControllerBase { +/** + * A PreferenceController handling the logic for permissions of apps. + */ +public class AppPermissionPreferenceController extends AppInfoPreferenceControllerBase implements + LifecycleObserver, OnStart, OnStop { private static final String TAG = "PermissionPrefControl"; private static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton"; + private final PackageManager mPackageManager; + private String mPackageName; @VisibleForTesting @@ -73,8 +83,22 @@ public class AppPermissionPreferenceController extends AppInfoPreferenceControll } }; + private final PackageManager.OnPermissionsChangedListener mOnPermissionsChangedListener = + uid -> updateState(mPreference); + public AppPermissionPreferenceController(Context context, String key) { super(context, key); + mPackageManager = context.getPackageManager(); + } + + @Override + public void onStart() { + mPackageManager.addOnPermissionsChangeListener(mOnPermissionsChangedListener); + } + + @Override + public void onStop() { + mPackageManager.removeOnPermissionsChangeListener(mOnPermissionsChangedListener); } @Override diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index ef58c8a84a..66b93e17b4 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -501,6 +501,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new ShowFirstCrashDialogPreferenceController(context)); controllers.add(new AppsNotRespondingPreferenceController(context)); controllers.add(new NotificationChannelWarningsPreferenceController(context)); + controllers.add(new EnforceConversationShortcutsPreferenceController(context)); controllers.add(new AllowAppsOnExternalPreferenceController(context)); controllers.add(new ResizableActivityPreferenceController(context)); controllers.add(new FreeformWindowsPreferenceController(context)); diff --git a/src/com/android/settings/development/EnforceConversationShortcutsPreferenceController.java b/src/com/android/settings/development/EnforceConversationShortcutsPreferenceController.java new file mode 100644 index 0000000000..dd4cdcae83 --- /dev/null +++ b/src/com/android/settings/development/EnforceConversationShortcutsPreferenceController.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2020 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. + */ + +package com.android.settings.development; + +import android.content.Context; +import android.os.Build; +import android.provider.Settings; + +import androidx.annotation.VisibleForTesting; +import androidx.preference.Preference; +import androidx.preference.SwitchPreference; + +import com.android.settings.core.PreferenceControllerMixin; +import com.android.settingslib.development.DeveloperOptionsPreferenceController; + +public class EnforceConversationShortcutsPreferenceController extends + DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, + PreferenceControllerMixin { + + private static final String KEY = + "enforce_shortcuts_for_conversations"; + + @VisibleForTesting + final static int SETTING_VALUE_ON = 1; + @VisibleForTesting + final static int SETTING_VALUE_OFF = 0; + + final static int DEFAULT_VALUE = SETTING_VALUE_OFF; + + public EnforceConversationShortcutsPreferenceController(Context context) { + super(context); + } + + @Override + public String getPreferenceKey() { + return KEY; + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + final boolean isEnabled = (Boolean) newValue; + Settings.Global.putInt(mContext.getContentResolver(), + Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, + isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF); + return true; + } + + @Override + public void updateState(Preference preference) { + final int mode = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.REQUIRE_SHORTCUTS_FOR_CONVERSATIONS, DEFAULT_VALUE); + ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF); + } +} diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java index 9dbf948ec9..27960e123e 100644 --- a/src/com/android/settings/media/MediaOutputSlice.java +++ b/src/com/android/settings/media/MediaOutputSlice.java @@ -197,6 +197,8 @@ public class MediaOutputSlice implements CustomSliceable { } listBuilder.addInputRange(builder); } else { + Log.d(TAG, "addRow device = " + device.getName() + " MaxVolume = " + + device.getMaxVolume()); final ListBuilder.RowBuilder builder = getMediaDeviceRow(device); // Check end item visibility if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE @@ -266,16 +268,24 @@ public class MediaOutputSlice implements CustomSliceable { if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE && !device.isConnected()) { - // Append status to title only for the disconnected Bluetooth device. - final SpannableString spannableTitle = new SpannableString( - mContext.getString(R.string.media_output_disconnected_status, deviceName)); - spannableTitle.setSpan(new ForegroundColorSpan( - Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary)), - deviceName.length(), - spannableTitle.length(), SPAN_EXCLUSIVE_EXCLUSIVE); - rowBuilder.setTitle(spannableTitle); - rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon, - ListBuilder.ICON_IMAGE, spannableTitle)); + if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) { + rowBuilder.setTitle(deviceName); + rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon, + ListBuilder.ICON_IMAGE, deviceName)); + rowBuilder.setSubtitle(mContext.getText(R.string.media_output_switching)); + } else { + // Append status to title only for the disconnected Bluetooth device. + final SpannableString spannableTitle = new SpannableString( + mContext.getString(R.string.media_output_disconnected_status, deviceName)); + spannableTitle.setSpan(new ForegroundColorSpan( + Utils.getColorAttrDefaultColor(mContext, + android.R.attr.textColorSecondary)), + deviceName.length(), + spannableTitle.length(), SPAN_EXCLUSIVE_EXCLUSIVE); + rowBuilder.setTitle(spannableTitle); + rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon, + ListBuilder.ICON_IMAGE, spannableTitle)); + } } else { rowBuilder.setTitle(deviceName); rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon, diff --git a/src/com/android/settings/network/telephony/TelephonyConstants.java b/src/com/android/settings/network/telephony/TelephonyConstants.java index 2a2613cc49..78a177edcc 100644 --- a/src/com/android/settings/network/telephony/TelephonyConstants.java +++ b/src/com/android/settings/network/telephony/TelephonyConstants.java @@ -16,7 +16,6 @@ package com.android.settings.network.telephony; - import android.telephony.TelephonyManager; /** @@ -210,6 +209,12 @@ public class TelephonyConstants { * Copied from {@link android.telephony.RadioAccessFamily} */ public static class RadioAccessFamily { + /** + * TODO: get rid of RAF definition in RadioAccessFamily and + * use {@link TelephonyManager.NetworkTypeBitMask} + * TODO: public definition {@link TelephonyManager.NetworkTypeBitMask} is long. + * TODO: Convert from int * to long everywhere including HAL definitions. + */ // 2G public static final int RAF_UNKNOWN = (int) TelephonyManager.NETWORK_TYPE_BITMASK_UNKNOWN; public static final int RAF_GSM = (int) TelephonyManager.NETWORK_TYPE_BITMASK_GSM; @@ -245,9 +250,7 @@ public class TelephonyConstants { public static final int WCDMA = HS | RAF_UMTS; // 4G public static final int LTE = RAF_LTE | RAF_LTE_CA; - // 5G public static final int NR = RAF_NR; - } } diff --git a/src/com/android/settings/nfc/NfcDetectionPointController.java b/src/com/android/settings/nfc/NfcDetectionPointController.java new file mode 100644 index 0000000000..b2e8f6abde --- /dev/null +++ b/src/com/android/settings/nfc/NfcDetectionPointController.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 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. + */ + +package com.android.settings.nfc; + +import android.content.Context; + +import androidx.annotation.VisibleForTesting; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +/** + * Controller that used to show nfc detection point guidance + */ +public class NfcDetectionPointController extends BasePreferenceController { + private boolean mEnabled; + + public NfcDetectionPointController(Context context, String preferenceKey) { + super(context, preferenceKey); + mEnabled = mContext.getResources().getBoolean(R.bool.config_nfc_detection_point); + } + + @Override + public int getAvailabilityStatus() { + if (!mEnabled) { + return UNSUPPORTED_ON_DEVICE; + } + return AVAILABLE; + } + + @VisibleForTesting + public void setConfig(boolean value) { + mEnabled = value; + } +} diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java index 8d7695ff3d..d41268dcc5 100644 --- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java +++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java @@ -70,6 +70,8 @@ public class NotificationHistoryActivity extends Activity { private PackageManager mPm; private HistoryLoader.OnHistoryLoaderListener mOnHistoryLoaderListener = notifications -> { + findViewById(R.id.today_list).setVisibility( + notifications.isEmpty() ? View.GONE : View.VISIBLE); // for each package, new header and recycler view for (NotificationHistoryPackage nhp : notifications) { View viewForPackage = LayoutInflater.from(this) @@ -182,6 +184,10 @@ public class NotificationHistoryActivity extends Activity { } else { mHistoryOn.setVisibility(View.GONE); mHistoryOff.setVisibility(View.VISIBLE); + mHistoryOff.findViewById(R.id.history_off_title).setVisibility(View.VISIBLE); + mHistoryOff.findViewById(R.id.history_off_summary).setVisibility(View.VISIBLE); + mHistoryOff.findViewById(R.id.history_toggled_on_title).setVisibility(View.GONE); + mHistoryOff.findViewById(R.id.history_toggled_on_summary).setVisibility(View.GONE); mTodayView.removeAllViews(); } } @@ -232,7 +238,17 @@ public class NotificationHistoryActivity extends Activity { Settings.Secure.putInt(getContentResolver(), NOTIFICATION_HISTORY_ENABLED, isChecked ? 1 : 0); - toggleViews(isChecked); + mHistoryOn.setVisibility(View.GONE); + mHistoryOff.findViewById(R.id.history_off_title).setVisibility( + isChecked ? View.GONE : View.VISIBLE); + mHistoryOff.findViewById(R.id.history_off_summary).setVisibility( + isChecked ? View.GONE : View.VISIBLE); + mHistoryOff.findViewById(R.id.history_toggled_on_title).setVisibility( + isChecked ? View.VISIBLE : View.GONE); + mHistoryOff.findViewById(R.id.history_toggled_on_summary).setVisibility( + isChecked ? View.VISIBLE : View.GONE); + mTodayView.removeAllViews(); + mHistoryOff.setVisibility(View.VISIBLE); }; private final NotificationListenerService mListener = new NotificationListenerService() { diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java index 6ad4c94a8d..1b54e1a2f3 100644 --- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java +++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java @@ -235,6 +235,13 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements public void refreshPreferences() { final PreferenceScreen screen = getPreferenceScreen(); for (AbstractPreferenceController controller : mControllers) { + // WifiDetailPreferenceController2 gets the callback WifiEntryCallback#onUpdated, + // it can control the visibility change by itself. + // And WifiDetailPreferenceController2#updatePreference renew mEntityHeaderController + // instance which will cause icon reset. + if (controller instanceof WifiDetailPreferenceController2) { + continue; + } controller.displayPreference(screen); } } |