diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c946122efc4..2eaebb1173a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -174,7 +174,8 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2973,7 +3305,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2989,7 +3321,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3005,7 +3337,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3021,7 +3353,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3037,7 +3369,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3053,7 +3385,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3069,7 +3401,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -3121,6 +3453,22 @@ column="9"/> + + + + @@ -3149,7 +3497,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3165,7 +3513,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3181,26 +3529,10 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> - - - - @@ -3261,7 +3593,7 @@ errorLine2=" ^"> @@ -3277,7 +3609,7 @@ errorLine2=" ^"> @@ -3293,7 +3625,7 @@ errorLine2=" ^"> diff --git a/res/drawable/ic_homepage_about_v2.xml b/res/drawable/ic_homepage_about_v2.xml new file mode 100644 index 00000000000..c069bfc98ba --- /dev/null +++ b/res/drawable/ic_homepage_about_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_accessibility_v2.xml b/res/drawable/ic_homepage_accessibility_v2.xml new file mode 100644 index 00000000000..24ca8cf20f9 --- /dev/null +++ b/res/drawable/ic_homepage_accessibility_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_accounts_v2.xml b/res/drawable/ic_homepage_accounts_v2.xml new file mode 100644 index 00000000000..6ea981ff206 --- /dev/null +++ b/res/drawable/ic_homepage_accounts_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_apps_v2.xml b/res/drawable/ic_homepage_apps_v2.xml new file mode 100644 index 00000000000..c6ac0c4f6da --- /dev/null +++ b/res/drawable/ic_homepage_apps_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_battery_v2.xml b/res/drawable/ic_homepage_battery_v2.xml new file mode 100644 index 00000000000..680031fe592 --- /dev/null +++ b/res/drawable/ic_homepage_battery_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_connected_device_v2.xml b/res/drawable/ic_homepage_connected_device_v2.xml new file mode 100644 index 00000000000..f3e95d23f91 --- /dev/null +++ b/res/drawable/ic_homepage_connected_device_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_display_v2.xml b/res/drawable/ic_homepage_display_v2.xml new file mode 100644 index 00000000000..e4014ee4daa --- /dev/null +++ b/res/drawable/ic_homepage_display_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_emergency_v2.xml b/res/drawable/ic_homepage_emergency_v2.xml new file mode 100644 index 00000000000..86d1470f5ea --- /dev/null +++ b/res/drawable/ic_homepage_emergency_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_location_v2.xml b/res/drawable/ic_homepage_location_v2.xml new file mode 100644 index 00000000000..5dc72eb1855 --- /dev/null +++ b/res/drawable/ic_homepage_location_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_network_v2.xml b/res/drawable/ic_homepage_network_v2.xml new file mode 100644 index 00000000000..d3b33e96fe2 --- /dev/null +++ b/res/drawable/ic_homepage_network_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_notification_v2.xml b/res/drawable/ic_homepage_notification_v2.xml new file mode 100644 index 00000000000..9b57456f277 --- /dev/null +++ b/res/drawable/ic_homepage_notification_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_privacy_v2.xml b/res/drawable/ic_homepage_privacy_v2.xml new file mode 100644 index 00000000000..56e6da82ce8 --- /dev/null +++ b/res/drawable/ic_homepage_privacy_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_security_v2.xml b/res/drawable/ic_homepage_security_v2.xml new file mode 100644 index 00000000000..5e33add6613 --- /dev/null +++ b/res/drawable/ic_homepage_security_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_sound_v2.xml b/res/drawable/ic_homepage_sound_v2.xml new file mode 100644 index 00000000000..8561820e549 --- /dev/null +++ b/res/drawable/ic_homepage_sound_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_storage_v2.xml b/res/drawable/ic_homepage_storage_v2.xml new file mode 100644 index 00000000000..1a8b7d28b4e --- /dev/null +++ b/res/drawable/ic_homepage_storage_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_support_v2.xml b/res/drawable/ic_homepage_support_v2.xml new file mode 100644 index 00000000000..81399738279 --- /dev/null +++ b/res/drawable/ic_homepage_support_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_system_dashboard_v2.xml b/res/drawable/ic_homepage_system_dashboard_v2.xml new file mode 100644 index 00000000000..7c016a2080f --- /dev/null +++ b/res/drawable/ic_homepage_system_dashboard_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/drawable/ic_homepage_wallpaper_v2.xml b/res/drawable/ic_homepage_wallpaper_v2.xml new file mode 100644 index 00000000000..ee16339ac95 --- /dev/null +++ b/res/drawable/ic_homepage_wallpaper_v2.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/res/layout-sw300dp-land/font_size_activity.xml b/res/layout-sw300dp-land/font_size_activity.xml index 666470424ae..7703eb2fc75 100644 --- a/res/layout-sw300dp-land/font_size_activity.xml +++ b/res/layout-sw300dp-land/font_size_activity.xml @@ -36,7 +36,7 @@ android:padding="6dp" /> - - + diff --git a/res/layout-sw300dp-land/screen_zoom_activity.xml b/res/layout-sw300dp-land/screen_zoom_activity.xml index 0f1c000b000..1cdb5b439c6 100644 --- a/res/layout-sw300dp-land/screen_zoom_activity.xml +++ b/res/layout-sw300dp-land/screen_zoom_activity.xml @@ -38,7 +38,7 @@ android:padding="6dp" /> - - + diff --git a/res/layout/font_size_activity.xml b/res/layout/font_size_activity.xml index 32de37d0f89..c3b26ae7526 100644 --- a/res/layout/font_size_activity.xml +++ b/res/layout/font_size_activity.xml @@ -14,17 +14,18 @@ limitations under the License. --> - + + android:layout_height="wrap_content"> - + + android:padding="6dp"/> + android:elevation="2dp"/> + android:contentDescription="@string/font_size_make_smaller_desc"/> + android:contentDescription="@string/font_size_make_larger_desc"/> + android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"/> - + diff --git a/res/layout/font_size_preview.xml b/res/layout/font_size_preview.xml index 669ece05341..2b1773bcee3 100644 --- a/res/layout/font_size_preview.xml +++ b/res/layout/font_size_preview.xml @@ -14,7 +14,8 @@ limitations under the License. --> - @@ -57,4 +58,4 @@ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"/> - + diff --git a/res/layout/homepage_preference.xml b/res/layout/homepage_preference.xml new file mode 100644 index 00000000000..c08a74f2418 --- /dev/null +++ b/res/layout/homepage_preference.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/preview_seek_bar_view_pager.xml b/res/layout/preview_seek_bar_view_pager.xml index 12f26110b36..6ddff130451 100644 --- a/res/layout/preview_seek_bar_view_pager.xml +++ b/res/layout/preview_seek_bar_view_pager.xml @@ -25,7 +25,7 @@ diff --git a/res/layout/screen_zoom_activity.xml b/res/layout/screen_zoom_activity.xml index 4cfa7b6ae98..00831fbe55f 100644 --- a/res/layout/screen_zoom_activity.xml +++ b/res/layout/screen_zoom_activity.xml @@ -14,17 +14,18 @@ limitations under the License. --> - + + android:layout_height="wrap_content"> - + + android:padding="6dp"/> + android:elevation="2dp"/> + android:contentDescription="@string/screen_zoom_make_smaller_desc"/> + android:contentDescription="@string/screen_zoom_make_larger_desc"/> + android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"/> - + diff --git a/res/layout/screen_zoom_preview_1.xml b/res/layout/screen_zoom_preview_1.xml index 65d27ee6896..9290df95e4b 100644 --- a/res/layout/screen_zoom_preview_1.xml +++ b/res/layout/screen_zoom_preview_1.xml @@ -13,7 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - - + diff --git a/res/layout/screen_zoom_preview_settings.xml b/res/layout/screen_zoom_preview_settings.xml index 3401fcf1971..de163928a8b 100644 --- a/res/layout/screen_zoom_preview_settings.xml +++ b/res/layout/screen_zoom_preview_settings.xml @@ -14,7 +14,8 @@ limitations under the License. --> - - + diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml index d3e98c37ea3..c4dd15dc243 100644 --- a/res/layout/search_bar.xml +++ b/res/layout/search_bar.xml @@ -20,7 +20,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/search_bar_margin" + android:layout_marginTop="@dimen/search_bar_margin" + android:layout_marginStart="@dimen/search_bar_margin" + android:layout_marginEnd="@dimen/search_bar_margin" + android:layout_marginBottom="16dp" app:layout_scrollFlags="scroll|enterAlways"> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml index c5f67febfa9..a4f495a6507 100644 --- a/res/values-night/themes.xml +++ b/res/values-night/themes.xml @@ -44,4 +44,10 @@ + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index bc01d59fea1..7bd5971465f 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -116,6 +116,12 @@ 6dp + + 48dp + + + 12dp + 12dp diff --git a/res/values/strings.xml b/res/values/strings.xml index d687357e096..3a7cf8e4444 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4950,6 +4950,8 @@ Text and display Interaction controls + + Tap assistance Downloaded apps @@ -11666,11 +11668,9 @@ Do nothing - On (vibrate) + Vibrate - On (mute) - - Off + Mute Network details diff --git a/res/values/styles.xml b/res/values/styles.xml index ce6b09551a6..e75766d36e2 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -312,6 +312,12 @@ @dimen/search_bar_text_size + + + + + + + + diff --git a/res/values/themes.xml b/res/values/themes.xml index 01ea10302bf..fc692463dfa 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -72,7 +72,7 @@ true - + + diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml index 6efd8843ecf..126865cc44b 100644 --- a/res/xml/accessibility_settings.xml +++ b/res/xml/accessibility_settings.xml @@ -65,13 +65,6 @@ android:persistent="false" android:title="@string/interaction_control_category_title"> - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml index 32dad203e43..970ad217bfd 100644 --- a/res/xml/gestures.xml +++ b/res/xml/gestures.xml @@ -20,12 +20,6 @@ xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/gesture_preference_title"> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml index 3c65f7bc095..78dfe9b90b6 100644 --- a/res/xml/top_level_settings.xml +++ b/res/xml/top_level_settings.xml @@ -125,13 +125,12 @@ android:fragment="com.android.settings.accessibility.AccessibilitySettings" settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/> - - - - - - - + - - - - @@ -61,47 +61,47 @@ android:key="phone_essential" android:order="-100" settings:allowDividerAbove="false"> - - - - - - - - - - - - - - - - + + - - - - mCategoryListeners = new ArrayList<>(); + + protected CollapsingToolbarLayout mCollapsingToolbarLayout; private int mCategoriesUpdateTaskCount; @Override @@ -79,21 +86,30 @@ public class SettingsBaseActivity extends FragmentActivity { requestWindowFeature(Window.FEATURE_NO_TITLE); } // Apply SetupWizard light theme during setup flow. This is for SubSettings pages. - if (WizardManagerHelper.isAnySetupWizard(getIntent()) && this instanceof SubSettings) { + final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent()); + if (isAnySetupWizard && this instanceof SubSettings) { setTheme(R.style.LightTheme_SubSettings_SetupWizard); } - super.setContentView(R.layout.settings_base_layout); + if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME) + && isToolbarEnabled() && !isAnySetupWizard) { + super.setContentView(R.layout.settings_collapsing_base_layout); + mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar); + } else { + super.setContentView(R.layout.settings_base_layout); + } + + // This is to hide the toolbar from those pages which don't need a toolbar originally. final Toolbar toolbar = findViewById(R.id.action_bar); - if (theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) { + if (!isToolbarEnabled() || isAnySetupWizard) { toolbar.setVisibility(View.GONE); return; } setActionBar(toolbar); + initCollapsingToolbar(); if (DEBUG_TIMING) { - Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) - + " ms"); + Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms"); } } @@ -151,6 +167,70 @@ public class SettingsBaseActivity extends FragmentActivity { ((ViewGroup) findViewById(R.id.content_frame)).addView(view, params); } + @Override + public void setTitle(CharSequence title) { + if (mCollapsingToolbarLayout != null) { + mCollapsingToolbarLayout.setTitle(title); + } + super.setTitle(title); + } + + @Override + public void setTitle(int titleId) { + if (mCollapsingToolbarLayout != null) { + mCollapsingToolbarLayout.setTitle(getText(titleId)); + } + super.setTitle(titleId); + } + + /** + * SubSetting page should show a toolbar by default. If the page wouldn't show a toolbar, + * override this method and return false value. + * @return ture by default + */ + protected boolean isToolbarEnabled() { + return true; + } + + private void initCollapsingToolbar() { + if (mCollapsingToolbarLayout == null) { + return; + } + mCollapsingToolbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + v.removeOnLayoutChangeListener(this); + final int count = getLineCount(); + if (count > TOOLBAR_MAX_LINE_NUMBER) { + mCollapsingToolbarLayout + .setExpandedTitleTextAppearance(R.style.ToolbarText_MoreThanTwoLines); + } else { + mCollapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ToolbarText); + } + } + }); + } + + private int getLineCount() { + try { + final Class toolbarClazz = mCollapsingToolbarLayout.getClass(); + final Field textHelperField = toolbarClazz.getDeclaredField("collapsingTextHelper"); + textHelperField.setAccessible(true); + final Object textHelperObj = textHelperField.get(mCollapsingToolbarLayout); + + final Field layoutField = textHelperObj.getClass().getDeclaredField("textLayout"); + layoutField.setAccessible(true); + final Object layoutObj = layoutField.get(textHelperObj); + + final Method method = layoutObj.getClass().getDeclaredMethod("getLineCount"); + return (int) method.invoke(layoutObj); + } catch (Exception e) { + return 0; + } + } + + private void onCategoriesChanged(Set categories) { final int N = mCategoryListeners.size(); for (int i = 0; i < N; i++) { diff --git a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java index beef4f30073..5118b277b59 100644 --- a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java +++ b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java @@ -25,6 +25,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.text.TextUtils; +import android.util.FeatureFlagUtils; import android.util.Log; import androidx.preference.Preference; @@ -32,6 +33,8 @@ import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; +import com.android.settings.core.FeatureFlags; +import com.android.settings.homepage.RestrictedHomepagePreference; import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedTopLevelPreference; @@ -89,7 +92,11 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl @Override public void updateState(Preference preference) { - disablePreferenceIfManaged((RestrictedTopLevelPreference) preference); + if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) { + disablePreferenceIfManaged((RestrictedHomepagePreference) preference); + } else { + disablePreferenceIfManaged((RestrictedTopLevelPreference) preference); + } } @Override @@ -133,4 +140,18 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl } } } + + private void disablePreferenceIfManaged(RestrictedHomepagePreference pref) { + final String restriction = DISALLOW_SET_WALLPAPER; + if (pref != null) { + pref.setDisabledByAdmin(null); + if (RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext, + restriction, UserHandle.myUserId())) { + // Do not show the admin dialog for system restriction. + pref.setEnabled(false); + } else { + pref.checkRestrictionAndSetDisabled(restriction); + } + } + } } diff --git a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java index 7c7be096841..ca1f1c775b4 100644 --- a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java +++ b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java @@ -20,20 +20,84 @@ import static android.provider.Settings.Secure.VOLUME_HUSH_GESTURE; import static android.provider.Settings.Secure.VOLUME_HUSH_MUTE; import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE; +import android.content.ContentResolver; import android.content.Context; +import android.database.ContentObserver; +import android.net.Uri; +import android.os.Handler; import android.provider.Settings; -import com.android.settings.R; -import com.android.settings.core.BasePreferenceController; +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; -public class PreventRingingParentPreferenceController extends BasePreferenceController { +import com.android.settings.R; +import com.android.settings.core.TogglePreferenceController; +import com.android.settings.widget.PrimarySwitchPreference; +import com.android.settingslib.core.lifecycle.LifecycleObserver; +import com.android.settingslib.core.lifecycle.events.OnStart; +import com.android.settingslib.core.lifecycle.events.OnStop; + +/** The controller manages the behaviour of the Prevent Ringing gesture setting. */ +public class PreventRingingParentPreferenceController extends TogglePreferenceController + implements LifecycleObserver, OnStart, OnStop { final String SECURE_KEY = VOLUME_HUSH_GESTURE; + private PrimarySwitchPreference mPreference; + private SettingObserver mSettingObserver; + public PreventRingingParentPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + mPreference = screen.findPreference(getPreferenceKey()); + mSettingObserver = new SettingObserver(mPreference); + } + + @Override + public boolean isChecked() { + final int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.VOLUME_HUSH_GESTURE, + Settings.Secure.VOLUME_HUSH_VIBRATE); + return preventRinging != Settings.Secure.VOLUME_HUSH_OFF; + } + + @Override + public boolean setChecked(boolean isChecked) { + final int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE); + final int newRingingSetting = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF + ? Settings.Secure.VOLUME_HUSH_VIBRATE + : preventRingingSetting; + + return Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.VOLUME_HUSH_GESTURE, isChecked + ? newRingingSetting + : Settings.Secure.VOLUME_HUSH_OFF); + } + + @Override + public void updateState(Preference preference) { + super.updateState(preference); + final int value = Settings.Secure.getInt( + mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE); + CharSequence summary; + switch (value) { + case VOLUME_HUSH_VIBRATE: + summary = mContext.getText(R.string.prevent_ringing_option_vibrate_summary); + break; + case VOLUME_HUSH_MUTE: + summary = mContext.getText(R.string.prevent_ringing_option_mute_summary); + break; + default: + summary = null; + } + preference.setSummary(summary); + } + @Override public int getAvailabilityStatus() { return mContext.getResources().getBoolean( @@ -42,20 +106,45 @@ public class PreventRingingParentPreferenceController extends BasePreferenceCont } @Override - public CharSequence getSummary() { - int value = Settings.Secure.getInt( - mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE); - int summary; - switch (value) { - case VOLUME_HUSH_VIBRATE: - summary = R.string.prevent_ringing_option_vibrate_summary; - break; - case VOLUME_HUSH_MUTE: - summary = R.string.prevent_ringing_option_mute_summary; - break; - default: - summary = R.string.prevent_ringing_option_none_summary; + public void onStart() { + if (mSettingObserver != null) { + mSettingObserver.register(mContext.getContentResolver()); + mSettingObserver.onChange(false, null); + } + } + + @Override + public void onStop() { + if (mSettingObserver != null) { + mSettingObserver.unregister(mContext.getContentResolver()); + } + } + + private class SettingObserver extends ContentObserver { + private final Uri mVolumeHushGestureUri = Settings.Secure.getUriFor( + Settings.Secure.VOLUME_HUSH_GESTURE); + + private final Preference mPreference; + + SettingObserver(Preference preference) { + super(new Handler()); + mPreference = preference; + } + + public void register(ContentResolver cr) { + cr.registerContentObserver(mVolumeHushGestureUri, false, this); + } + + public void unregister(ContentResolver cr) { + cr.unregisterContentObserver(this); + } + + @Override + public void onChange(boolean selfChange, Uri uri) { + super.onChange(selfChange, uri); + if (uri == null || mVolumeHushGestureUri.equals(uri)) { + updateState(mPreference); + } } - return mContext.getText(summary); } } diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java index 9545939255b..be67b5a4f9e 100644 --- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java +++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java @@ -16,11 +16,7 @@ package com.android.settings.gestures; -import android.content.ContentResolver; import android.content.Context; -import android.database.ContentObserver; -import android.net.Uri; -import android.os.Handler; import android.provider.Settings; import android.widget.Switch; @@ -39,7 +35,6 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference private static final String KEY = "gesture_prevent_ringing_switch"; private final Context mContext; - private SettingObserver mSettingObserver; @VisibleForTesting SwitchBar mSwitch; @@ -60,7 +55,6 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference if (isAvailable()) { LayoutPreference pref = screen.findPreference(getPreferenceKey()); if (pref != null) { - mSettingObserver = new SettingObserver(pref); pref.setOnPreferenceClickListener(preference -> { int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE, @@ -113,32 +107,4 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference ? newRingingSetting : Settings.Secure.VOLUME_HUSH_OFF); } - - private class SettingObserver extends ContentObserver { - private final Uri VOLUME_HUSH_GESTURE = Settings.Secure.getUriFor( - Settings.Secure.VOLUME_HUSH_GESTURE); - - private final Preference mPreference; - - public SettingObserver(Preference preference) { - super(new Handler()); - mPreference = preference; - } - - public void register(ContentResolver cr) { - cr.registerContentObserver(VOLUME_HUSH_GESTURE, false, this); - } - - public void unregister(ContentResolver cr) { - cr.unregisterContentObserver(this); - } - - @Override - public void onChange(boolean selfChange, Uri uri) { - super.onChange(selfChange, uri); - if (uri == null || VOLUME_HUSH_GESTURE.equals(uri)) { - updateState(mPreference); - } - } - } } diff --git a/src/com/android/settings/homepage/HomePagePreference.java b/src/com/android/settings/homepage/HomePagePreference.java new file mode 100644 index 00000000000..41d59b72d29 --- /dev/null +++ b/src/com/android/settings/homepage/HomePagePreference.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021 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.homepage; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.preference.Preference; + +import com.android.settings.R; + +/** A customized layout for homepage preference. */ +public class HomePagePreference extends Preference { + + public HomePagePreference(Context context) { + super(context); + setLayoutResource(R.layout.homepage_preference); + } + + public HomePagePreference(Context context, AttributeSet attrs) { + super(context, attrs); + setLayoutResource(R.layout.homepage_preference); + } + + public HomePagePreference(Context context, AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, /* defStyleRes= */ 0); + setLayoutResource(R.layout.homepage_preference); + } + + public HomePagePreference(Context context, AttributeSet attrs, + int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + setLayoutResource(R.layout.homepage_preference); + } +} diff --git a/src/com/android/settings/homepage/RestrictedHomepagePreference.java b/src/com/android/settings/homepage/RestrictedHomepagePreference.java new file mode 100644 index 00000000000..47b552c1ee2 --- /dev/null +++ b/src/com/android/settings/homepage/RestrictedHomepagePreference.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2021 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.homepage; + +import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; + +import android.content.Context; +import android.os.UserHandle; +import android.util.AttributeSet; + +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.PreferenceManager; +import androidx.preference.PreferenceViewHolder; + +import com.android.settings.R; +import com.android.settingslib.RestrictedPreferenceHelper; + +/** Homepage preference that can be disabled by a device admin using a user restriction. */ +public class RestrictedHomepagePreference extends HomePagePreference { + private RestrictedPreferenceHelper mHelper; + + public RestrictedHomepagePreference(Context context, AttributeSet attrs, + int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + mHelper = new RestrictedPreferenceHelper(context, /* preference= */ this, attrs); + } + + public RestrictedHomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) { + this(context, attrs, defStyleAttr, /* defStyleRes= */ 0); + } + + public RestrictedHomepagePreference(Context context, AttributeSet attrs) { + this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle, + android.R.attr.preferenceStyle)); + } + + public RestrictedHomepagePreference(Context context) { + this(context, /* attrs= */ null); + } + + @Override + public void onBindViewHolder(PreferenceViewHolder holder) { + super.onBindViewHolder(holder); + mHelper.onBindViewHolder(holder); + } + + @Override + public void performClick() { + if (!mHelper.performClick()) { + super.performClick(); + } + } + + @Override + protected void onAttachedToHierarchy(PreferenceManager preferenceManager) { + mHelper.onAttachedToHierarchy(); + super.onAttachedToHierarchy(preferenceManager); + } + + /** + * Set the user restriction and disable this preference. + * + * @param userRestriction constant from {@link android.os.UserManager} + */ + public void checkRestrictionAndSetDisabled(String userRestriction) { + mHelper.checkRestrictionAndSetDisabled(userRestriction, UserHandle.myUserId()); + } + + /** + * Set the user restriction and disable this preference for the given user. + * + * @param userRestriction constant from {@link android.os.UserManager} + * @param userId user to check the restriction for. + */ + public void checkRestrictionAndSetDisabled(String userRestriction, int userId) { + mHelper.checkRestrictionAndSetDisabled(userRestriction, userId); + } + + @Override + public void setEnabled(boolean enabled) { + if (enabled && isDisabledByAdmin()) { + mHelper.setDisabledByAdmin(/* admin= */ null); + return; + } + super.setEnabled(enabled); + } + + /** + * Check whether this preference is disabled by admin. + * + * @return true if this preference is disabled by admin. + */ + public boolean isDisabledByAdmin() { + return mHelper.isDisabledByAdmin(); + } + + /** + * Disable preference based on the enforce admin. + * + * @param admin details of the admin who enforced the restriction. If it is {@code null}, then + * this preference will be enabled. Otherwise, it will be disabled. + */ + public void setDisabledByAdmin(EnforcedAdmin admin) { + if (mHelper.setDisabledByAdmin(admin)) { + notifyChanged(); + } + } +} diff --git a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java index 0ad241e7431..1b3ee10b233 100644 --- a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java +++ b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java @@ -143,8 +143,8 @@ public class FaceSetupSlice implements CustomSliceable { private static RowBuilder buildRowBuilder(CharSequence title, CharSequence subTitle, IconCompat icon, Context context, Intent intent) { final SliceAction primarySliceAction = SliceAction.createDeeplink( - PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED), icon, ListBuilder.ICON_IMAGE, - title); + PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE), + icon, ListBuilder.ICON_IMAGE, title); return new RowBuilder() .setTitleItem(icon, ListBuilder.ICON_IMAGE) .setTitle(title) diff --git a/src/com/android/settings/inputmethod/UserDictionarySettings.java b/src/com/android/settings/inputmethod/UserDictionarySettings.java index 67420a2c5df..5e3e7495359 100644 --- a/src/com/android/settings/inputmethod/UserDictionarySettings.java +++ b/src/com/android/settings/inputmethod/UserDictionarySettings.java @@ -26,6 +26,7 @@ import android.database.Cursor; import android.os.Bundle; import android.provider.UserDictionary; import android.text.TextUtils; +import android.util.FeatureFlagUtils; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -44,6 +45,7 @@ import androidx.loader.app.LoaderManager; import androidx.loader.content.Loader; import com.android.settings.R; +import com.android.settings.core.FeatureFlags; import com.android.settings.core.SubSettingLauncher; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.instrumentation.Instrumentable; @@ -104,6 +106,10 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // TODO(b/176883483): Remove the title after material component updated + if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { + getActivity().setTitle(R.string.user_dict_settings_title); + } // Show the language as a subtitle of the action bar final ActionBar actionBar = getActivity().getActionBar(); if (actionBar != null) { diff --git a/src/com/android/settings/network/telephony/EuiccOperationSidecar.java b/src/com/android/settings/network/telephony/EuiccOperationSidecar.java index a637cc2339f..0ee6d95fa83 100644 --- a/src/com/android/settings/network/telephony/EuiccOperationSidecar.java +++ b/src/com/android/settings/network/telephony/EuiccOperationSidecar.java @@ -99,7 +99,8 @@ public abstract class EuiccOperationSidecar extends SidecarFragment { Intent intent = new Intent(getReceiverAction()); intent.putExtra(EXTRA_OP_ID, mOpId); return PendingIntent.getBroadcast( - getContext(), REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + getContext(), REQUEST_CODE, intent, + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); } @Override diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java index 7c9bac0cf06..106f3368638 100644 --- a/src/com/android/settings/network/telephony/MobileDataSlice.java +++ b/src/com/android/settings/network/telephony/MobileDataSlice.java @@ -172,8 +172,8 @@ public class MobileDataSlice implements CustomSliceable { private PendingIntent getPrimaryAction() { final Intent intent = getIntent(); - return PendingIntent.getActivity(mContext, 0 /* requestCode */, - intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */); + return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, + PendingIntent.FLAG_IMMUTABLE); } /** diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java index b179770d485..92f0054d2e7 100644 --- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java +++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java @@ -115,6 +115,9 @@ public class MobileNetworkActivity extends SettingsBaseActivity final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); + // TODO(b/176882938): Enable title after material component updated + // If CollapsingToolbarLayout is applied, the old action bar won't show title. + actionBar.setDisplayShowTitleEnabled(mCollapsingToolbarLayout == null); } getProxySubscriptionManager().setLifecycle(getLifecycle()); diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java index a17298f9d79..27e2b726c1f 100644 --- a/src/com/android/settings/notification/RedactionInterstitial.java +++ b/src/com/android/settings/notification/RedactionInterstitial.java @@ -77,6 +77,11 @@ public class RedactionInterstitial extends SettingsActivity { findViewById(R.id.content_parent).setFitsSystemWindows(false); } + @Override + protected boolean isToolbarEnabled() { + return false; + } + /** * Create an intent for launching RedactionInterstitial. * diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index 1ad093fad35..fc209b8cff3 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -26,6 +26,7 @@ import android.os.Message; import android.os.UserHandle; import android.preference.SeekBarVolumizer; import android.text.TextUtils; +import android.util.FeatureFlagUtils; import androidx.annotation.VisibleForTesting; import androidx.preference.ListPreference; @@ -33,6 +34,7 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.RingtonePreference; +import com.android.settings.core.FeatureFlags; import com.android.settings.core.OnActivityResultListener; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.search.BaseSearchIndexProvider; @@ -152,6 +154,9 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult @Override protected int getPreferenceScreenResId() { + if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { + return R.xml.sound_settings_v2; + } return R.xml.sound_settings; } diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java index 312bf75b284..64a4699cda9 100644 --- a/src/com/android/settings/panel/InternetConnectivityPanel.java +++ b/src/com/android/settings/panel/InternetConnectivityPanel.java @@ -34,10 +34,6 @@ import java.util.List; /** * Represents the Internet Connectivity Panel. - * - *

- * Displays Wifi (full Slice) and Airplane mode. - *

*/ public class InternetConnectivityPanel implements PanelContent { @@ -78,6 +74,21 @@ public class InternetConnectivityPanel implements PanelContent { .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } + @Override + public boolean isCustomizedButtonUsed() { + return Utils.isProviderModelEnabled(mContext); + } + + @Override + public CharSequence getCustomizedButtonTitle() { + return mContext.getText(R.string.settings_button); + } + + @Override + public void onClickCustomizedButton() { + mContext.startActivity(getSeeMoreIntent()); + } + @Override public int getMetricsCategory() { return SettingsEnums.PANEL_INTERNET_CONNECTIVITY; diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java index cc27683933e..8eec24fa148 100644 --- a/src/com/android/settings/panel/PanelFragment.java +++ b/src/com/android/settings/panel/PanelFragment.java @@ -452,13 +452,13 @@ public class PanelFragment extends Fragment { View.OnClickListener getSeeMoreListener() { return (v) -> { mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE; + final FragmentActivity activity = getActivity(); if (mPanel.isCustomizedButtonUsed()) { mPanel.onClickCustomizedButton(); } else { - final FragmentActivity activity = getActivity(); activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0); - activity.finish(); } + activity.finish(); }; } diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java index 0c84ba97628..f5e23fa04f2 100644 --- a/src/com/android/settings/password/ChooseLockPassword.java +++ b/src/com/android/settings/password/ChooseLockPassword.java @@ -184,6 +184,11 @@ public class ChooseLockPassword extends SettingsActivity { return false; } + @Override + protected boolean isToolbarEnabled() { + return false; + } + /* package */ Class getFragmentClass() { return ChooseLockPasswordFragment.class; } diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java index 6e9cf981509..c52b4104288 100644 --- a/src/com/android/settings/password/ChooseLockPattern.java +++ b/src/com/android/settings/password/ChooseLockPattern.java @@ -194,6 +194,11 @@ public class ChooseLockPattern extends SettingsActivity { return super.onKeyDown(keyCode, event); } + @Override + protected boolean isToolbarEnabled() { + return false; + } + public static class ChooseLockPatternFragment extends InstrumentedFragment implements SaveAndFinishWorker.Listener { diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java index 3ecff580d33..f0b50a1bfec 100644 --- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java +++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java @@ -176,6 +176,11 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi } } + @Override + protected boolean isToolbarEnabled() { + return false; + } + public void prepareEnterAnimation() { getFragment().prepareEnterAnimation(); } diff --git a/src/com/android/settings/password/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java index e82dc94e124..25f5a348904 100644 --- a/src/com/android/settings/password/SetupChooseLockPassword.java +++ b/src/com/android/settings/password/SetupChooseLockPassword.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; -import android.widget.LinearLayout; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; @@ -65,8 +64,7 @@ public class SetupChooseLockPassword extends ChooseLockPassword { @Override protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); - LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent); - layout.setFitsSystemWindows(false); + findViewById(R.id.content_parent).setFitsSystemWindows(false); } public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java index b4bd4096da1..4b46939ace3 100644 --- a/src/com/android/settings/sim/SimSelectNotification.java +++ b/src/com/android/settings/sim/SimSelectNotification.java @@ -226,7 +226,7 @@ public class SimSelectNotification extends BroadcastReceiver { resultIntent.setPackage(SETTINGS_PACKAGE_NAME); resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); @@ -264,7 +264,7 @@ public class SimSelectNotification extends BroadcastReceiver { resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId); resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.setContentIntent(resultPendingIntent); // Notify the notification. @@ -312,7 +312,7 @@ public class SimSelectNotification extends BroadcastReceiver { resultIntent.putExtra(Intent.EXTRA_TEXT, "help_uri_sim_combination_warning"); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); builder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java index afab8c3cf77..4467d66e76c 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java @@ -18,9 +18,9 @@ package com.android.settings.wifi.calling; import static android.app.slice.Slice.EXTRA_TOGGLE_STATE; +import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI; import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_URI; -import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME; import android.app.PendingIntent; import android.content.ComponentName; @@ -539,7 +539,8 @@ public class WifiCallingSliceHelper { */ public static PendingIntent getSettingsIntent(Context context) { final Intent intent = new Intent(Settings.ACTION_SETTINGS); - return PendingIntent.getActivity(context, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */); + return PendingIntent.getActivity(context, 0 /* requestCode */, intent, + PendingIntent.FLAG_IMMUTABLE); } private PendingIntent getBroadcastIntent(String action) { @@ -547,7 +548,7 @@ public class WifiCallingSliceHelper { intent.setClass(mContext, SliceBroadcastReceiver.class); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); } /** @@ -557,7 +558,8 @@ public class WifiCallingSliceHelper { final Intent intent = new Intent(action); intent.setPackage(SETTINGS_PACKAGE_NAME); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */); + return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, + PendingIntent.FLAG_IMMUTABLE); } private Resources getResourcesForSubId(int subId) { diff --git a/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java new file mode 100644 index 00000000000..093ea0377f1 --- /dev/null +++ b/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021 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.accessibility; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; + +import androidx.test.core.app.ApplicationProvider; + +import com.android.settings.R; +import com.android.settings.testutils.XmlTestUtils; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; + +import java.util.List; + +@RunWith(RobolectricTestRunner.class) +/** Tests for {@link TapAssistanceFragment}. */ +public class TapAssistanceFragmentTest { + + private Context mContext = ApplicationProvider.getApplicationContext(); + + @Test + public void getNonIndexableKeys_existInXmlLayout() { + final List niks = TapAssistanceFragment.SEARCH_INDEX_DATA_PROVIDER + .getNonIndexableKeys(mContext); + final List keys = + XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_tap_assistance); + + assertThat(keys).containsAtLeastElementsIn(niks); + } +} diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java index 15e9bdaddcc..dffd7fb944a 100644 --- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java +++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java @@ -88,14 +88,16 @@ public class PlatformCompatDashboardTest { public void setUp() throws RemoteException, NameNotFoundException { MockitoAnnotations.initMocks(this); mChanges = new CompatibilityChangeInfo[5]; - mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, ""); - mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, ""); - mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, - ""); - mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, - ""); - mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false, - ""); + mChanges[0] = new CompatibilityChangeInfo( + 1L, "Default_Enabled", 0, 0, false, false, "", false); + mChanges[1] = new CompatibilityChangeInfo( + 2L, "Default_Disabled", 0, 0, true, false, "", false); + mChanges[2] = new CompatibilityChangeInfo( + 3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false); + mChanges[3] = new CompatibilityChangeInfo( + 4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false); + mChanges[4] = new CompatibilityChangeInfo( + 5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false); when(mPlatformCompat.listUIChanges()).thenReturn(mChanges); when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator); // By default, allow any change @@ -208,7 +210,8 @@ public class PlatformCompatDashboardTest { for (int i = 0; i < mChanges.length; ++i) { changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i].getName(), -1, mChanges[i].getEnableSinceTargetSdk(), mChanges[i].getDisabled(), - mChanges[i].getLoggingOnly(), mChanges[i].getDescription())); + mChanges[i].getLoggingOnly(), mChanges[i].getDescription(), + mChanges[i].getOverridable())); } PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd, diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java index c752eb98232..9e4877c954f 100644 --- a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java @@ -32,6 +32,8 @@ import android.content.Context; import android.content.res.Resources; import android.provider.Settings; +import androidx.preference.Preference; + import com.android.settings.R; import org.junit.Before; @@ -50,12 +52,14 @@ public class PreventRingingParentPreferenceControllerTest { private Context mContext; private PreventRingingParentPreferenceController mController; + private Preference mPreference; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application.getApplicationContext()); mController = new PreventRingingParentPreferenceController(mContext, "test_key"); + mPreference = new Preference(mContext); } @Test @@ -80,17 +84,43 @@ public class PreventRingingParentPreferenceControllerTest { public void updateState_summaryUpdated() { Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, VOLUME_HUSH_MUTE); - assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText( + mController.updateState(mPreference); + assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText( R.string.prevent_ringing_option_mute_summary)); Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, VOLUME_HUSH_VIBRATE); - assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText( + mController.updateState(mPreference); + assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText( R.string.prevent_ringing_option_vibrate_summary)); Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, VOLUME_HUSH_OFF); - assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText( - R.string.prevent_ringing_option_none_summary)); + mController.updateState(mPreference); + assertThat(mPreference.getSummary()).isEqualTo(null); + } + + @Test + public void isChecked_vibrate_shouldReturnTrue() { + Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, + VOLUME_HUSH_VIBRATE); + + assertThat(mController.isChecked()).isTrue(); + } + + @Test + public void isChecked_mute_shouldReturnTrue() { + Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, + VOLUME_HUSH_MUTE); + + assertThat(mController.isChecked()).isTrue(); + } + + @Test + public void isChecked_off_shouldReturnFalse() { + Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE, + VOLUME_HUSH_OFF); + + assertThat(mController.isChecked()).isFalse(); } } diff --git a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java index d9f56debc02..eb82d31745e 100644 --- a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java +++ b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java @@ -20,10 +20,12 @@ package com.android.settings.panel; import static com.google.common.truth.Truth.assertThat; import android.net.Uri; +import android.os.SystemProperties; import com.android.settings.network.AirplaneModePreferenceController; import com.android.settings.slices.CustomSliceRegistry; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,14 +39,25 @@ import java.util.List; public class InternetConnectivityPanelTest { private InternetConnectivityPanel mPanel; + private static final String SETTINGS_PROVIDER_MODEL = + "persist.sys.fflag.override.settings_provider_model"; + private boolean mSettingsProviderModelState; @Before public void setUp() { mPanel = InternetConnectivityPanel.create(RuntimeEnvironment.application); + mSettingsProviderModelState = SystemProperties.getBoolean(SETTINGS_PROVIDER_MODEL, false); + } + + @After + public void tearDown() { + SystemProperties.set(SETTINGS_PROVIDER_MODEL, + mSettingsProviderModelState ? "true" : "false"); } @Test - public void getSlices_containsNecessarySlices() { + public void getSlices_providerModelDisabled_containsNecessarySlices() { + SystemProperties.set(SETTINGS_PROVIDER_MODEL, "false"); final List uris = mPanel.getSlices(); assertThat(uris).containsExactly( @@ -53,6 +66,16 @@ public class InternetConnectivityPanelTest { CustomSliceRegistry.WIFI_SLICE_URI); } + @Test + public void getSlices_providerModelEnabled_containsNecessarySlices() { + SystemProperties.set(SETTINGS_PROVIDER_MODEL, "true"); + final List uris = mPanel.getSlices(); + + assertThat(uris).containsExactly( + CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI, + CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI); + } + @Test public void getSeeMoreIntent_notNull() { assertThat(mPanel.getSeeMoreIntent()).isNotNull(); diff --git a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java index 84e88cb9b4c..e08893bd823 100644 --- a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java +++ b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java @@ -59,6 +59,7 @@ import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; +import android.util.DisplayMetrics; import com.android.settings.R; import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; @@ -89,6 +90,8 @@ public class SimSelectNotificationTest { private Resources mResources; @Mock private SubscriptionInfo mSubInfo; + @Mock + private DisplayMetrics mDisplayMetrics; private final String mFakeDisplayName = "fake_display_name"; private final CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title"; @@ -141,6 +144,9 @@ public class SimSelectNotificationTest { .thenReturn(mFakeDualCdmaWarningTitle); when(mResources.getString(R.string.dual_cdma_sim_warning_notification_summary, mSimCombinationName)).thenReturn(mFakeDualCdmaWarningSummary); + + when(mResources.getDisplayMetrics()).thenReturn(mDisplayMetrics); + mDisplayMetrics.density = 1.5f; } @Test @@ -275,4 +281,3 @@ public class SimSelectNotificationTest { assertThat(notification.getValue().contentIntent).isNotNull(); } } - diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java index 0dcf6852fad..dbe77189e8f 100644 --- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java +++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java @@ -397,14 +397,15 @@ public class WifiCallingSliceHelperTest { final Intent intent = new Intent(action); intent.setClass(mContext, SliceBroadcastReceiver.class); return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); } private PendingIntent getActivityIntent(String action) { final Intent intent = new Intent(action); intent.setPackage(SETTINGS_PACKAGE_NAME); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */); + return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, + PendingIntent.FLAG_IMMUTABLE); } private void assertTitle(List sliceItems, String title) {