Snap for 5571215 from 4891ea2d44 to qt-release
Change-Id: Id7067946e5e3f9eb53d39673a9e71a93e5aed04e
This commit is contained in:
24
res/drawable/ic_partial_system_update_current.xml
Normal file
24
res/drawable/ic_partial_system_update_current.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
Copyright (C) 2019 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="20.0"
|
||||
android:viewportHeight="22.0">
|
||||
<path
|
||||
android:fillColor="#FF1E8E3E"
|
||||
android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
|
||||
</vector>
|
||||
24
res/drawable/ic_partial_system_update_stale.xml
Normal file
24
res/drawable/ic_partial_system_update_stale.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
Copyright (C) 2019 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="20.0"
|
||||
android:viewportHeight="22.0">
|
||||
<path
|
||||
android:fillColor="#FFD93025"
|
||||
android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
|
||||
</vector>
|
||||
@@ -15,41 +15,32 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/preview_viewport"
|
||||
android:clipToPadding="true"
|
||||
android:clipChildren="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/captioning_preview_height"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/caption_background"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/preview_viewport"
|
||||
android:id="@+id/preview_window"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/captioning_preview_height" >
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/caption_background" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/preview_window"
|
||||
android:layout_width="match_parent"
|
||||
<com.android.internal.widget.SubtitleView
|
||||
android:id="@+id/preview_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|start"
|
||||
android:padding="16dp" >
|
||||
|
||||
<com.android.internal.widget.SubtitleView
|
||||
android:id="@+id/preview_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/captioning_preview_text" />
|
||||
</FrameLayout>
|
||||
android:text="@string/captioning_preview_text"/>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/properties_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="true"
|
||||
android:clipToPadding="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_background"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -890,6 +890,8 @@
|
||||
<string name="security_settings_face_preference_title">Face authentication</string>
|
||||
<!-- Introduction title shown in face enrollment education screen [CHAR LIMIT=40] -->
|
||||
<string name="security_settings_face_enroll_education_title">How to set up Face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen for accessibility [CHAR LIMI=40]-->
|
||||
<string name="security_settings_face_enroll_education_title_accessibility">Set up Face unlock</string>
|
||||
<!-- Introduction title shown in face enrollment education screen to show the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
|
||||
<string name="security_settings_face_enroll_education_title_unlock_disabled">Use your face to authenticate</string>
|
||||
<!-- Introduction detail message shown in face education [CHAR LIMIT=NONE] -->
|
||||
@@ -4815,7 +4817,7 @@
|
||||
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
|
||||
<string name="interaction_control_category_title">Interaction controls</string>
|
||||
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
|
||||
<string name="user_installed_services_category_title">Downloaded services</string>
|
||||
<string name="user_installed_services_category_title">Downloaded apps</string>
|
||||
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
|
||||
<string name="experimental_category_title">Experimental</string>
|
||||
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
|
||||
@@ -4921,7 +4923,7 @@
|
||||
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
|
||||
<string name="accessibility_touch_vibration_title">Touch feedback</string>
|
||||
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
|
||||
<string name="accessibility_service_master_switch_title">Use service</string>
|
||||
<string name="accessibility_service_master_switch_title">Use <xliff:g id="service" example="TalkBack">%1$s</xliff:g></string>
|
||||
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
|
||||
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
|
||||
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
|
||||
@@ -5147,7 +5149,7 @@
|
||||
</string>
|
||||
|
||||
<!-- Title for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_action_perform_title">View and platform actions</string>
|
||||
<string name="accessibility_service_action_perform_title">View and perform actions</string>
|
||||
|
||||
<!-- Description for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_service_action_perform_description">It can track your interactions
|
||||
@@ -10056,6 +10058,12 @@
|
||||
<!-- [CHAR LIMIT=60] Name of setting that changes the UI to dark -->
|
||||
<string name="dark_ui_mode">Dark Theme</string>
|
||||
|
||||
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is still on-->
|
||||
<string name="dark_ui_mode_disabled_summary_dark_theme_on">On / Temporarily disabled due to Battery Saver</string>
|
||||
|
||||
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
|
||||
<string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
|
||||
|
||||
<!-- [CHAR_LIMIT=NONE] Summary that is shown in the footer when dark mode is selected -->
|
||||
<string name="dark_ui_settings_dark_summary">Supported apps will also switch to dark theme</string>
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
android:key="captioning_preference_screen"
|
||||
android:title="@string/accessibility_captioning_title" >
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="caption_preview"
|
||||
android:title="@string/summary_placeholder"
|
||||
android:layout="@layout/captioning_preview"
|
||||
settings:searchable="false"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="standard"
|
||||
android:title="@string/captioning_standard_options_title" >
|
||||
|
||||
@@ -22,13 +22,8 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFrameLayout;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnLayoutChangeListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||
|
||||
@@ -46,6 +41,7 @@ import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.ToggleSwitch;
|
||||
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -54,6 +50,7 @@ import java.util.Locale;
|
||||
*/
|
||||
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
implements OnPreferenceChangeListener, OnValueChangedListener {
|
||||
private static final String PREF_CAPTION_PREVIEW = "caption_preview";
|
||||
private static final String PREF_BACKGROUND_COLOR = "captioning_background_color";
|
||||
private static final String PREF_BACKGROUND_OPACITY = "captioning_background_opacity";
|
||||
private static final String PREF_FOREGROUND_COLOR = "captioning_foreground_color";
|
||||
@@ -115,43 +112,6 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
installUpdateListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View rootView = inflater.inflate(R.layout.captioning_preview, container, false);
|
||||
|
||||
// We have to do this now because PreferenceFrameLayout looks at it
|
||||
// only when the view is added.
|
||||
if (container instanceof PreferenceFrameLayout) {
|
||||
((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
|
||||
}
|
||||
|
||||
final View content = super.onCreateView(inflater, container, savedInstanceState);
|
||||
((ViewGroup) rootView.findViewById(R.id.properties_fragment)).addView(
|
||||
content, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
final boolean enabled = mCaptioningManager.isEnabled();
|
||||
mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
|
||||
mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
mPreviewWindow = view.findViewById(R.id.preview_window);
|
||||
mPreviewViewport = view.findViewById(R.id.preview_viewport);
|
||||
mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
refreshPreviewText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@@ -263,6 +223,19 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void initializeAllPreferences() {
|
||||
final LayoutPreference captionPreview = findPreference(PREF_CAPTION_PREVIEW);
|
||||
|
||||
final boolean enabled = mCaptioningManager.isEnabled();
|
||||
mPreviewText = captionPreview.findViewById(R.id.preview_text);
|
||||
mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
|
||||
|
||||
mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
|
||||
mPreviewViewport.addOnLayoutChangeListener(
|
||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
|
||||
-> refreshPreviewText());
|
||||
|
||||
mLocale = (LocalePreference) findPreference(PREF_LOCALE);
|
||||
mFontSize = (ListPreference) findPreference(PREF_FONT_SIZE);
|
||||
|
||||
@@ -370,9 +343,9 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
/**
|
||||
* Unpack the specified color value and update the preferences.
|
||||
*
|
||||
* @param color color preference
|
||||
* @param color color preference
|
||||
* @param opacity opacity preference
|
||||
* @param value packed value
|
||||
* @param value packed value
|
||||
*/
|
||||
private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) {
|
||||
final int colorValue;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static android.content.DialogInterface.BUTTON_POSITIVE;
|
||||
|
||||
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
|
||||
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
|
||||
|
||||
@@ -25,7 +23,6 @@ import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -191,6 +188,7 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
||||
((ShortcutServicePickerFragment) fragment).onServiceConfirmed(
|
||||
bundle.getString(EXTRA_KEY));
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,16 @@ public class ToggleAccessibilityServicePreferenceFragment
|
||||
mLockPatternUtils = new LockPatternUtils(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mSwitchBar.setLabelDelegate((boolean isChecked) -> {
|
||||
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||
return getString(R.string.accessibility_service_master_switch_title,
|
||||
info.getResolveInfo().loadLabel(getPackageManager()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
mSettingsContentObserver.register(getContentResolver());
|
||||
@@ -120,7 +130,7 @@ public class ToggleAccessibilityServicePreferenceFragment
|
||||
return serviceInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new IllegalStateException("ServiceInfo is not found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,18 +138,12 @@ public class ToggleAccessibilityServicePreferenceFragment
|
||||
switch (dialogId) {
|
||||
case DIALOG_ID_ENABLE_WARNING: {
|
||||
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
mDialog = AccessibilityServiceWarning
|
||||
.createCapabilitiesDialog(getActivity(), info, this);
|
||||
break;
|
||||
}
|
||||
case DIALOG_ID_DISABLE_WARNING: {
|
||||
AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
mDialog = AccessibilityServiceWarning
|
||||
.createDisableDialog(getActivity(), info, this);
|
||||
break;
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
@@ -59,19 +60,28 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|
||||
private View mIllustrationAccessibility;
|
||||
private Handler mHandler;
|
||||
private Intent mResultIntent;
|
||||
private TextView mDescriptionText;
|
||||
|
||||
private CompoundButton.OnCheckedChangeListener mSwitchDiversityListener =
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
int titleRes = isChecked ?
|
||||
R.string.security_settings_face_enroll_education_title_accessibility
|
||||
: R.string.security_settings_face_enroll_education_title;
|
||||
getLayout().setHeaderText(titleRes);
|
||||
setTitle(titleRes);
|
||||
|
||||
if (isChecked) {
|
||||
mIllustrationNormal.stop();
|
||||
mIllustrationNormal.setVisibility(View.INVISIBLE);
|
||||
mIllustrationAccessibility.setVisibility(View.VISIBLE);
|
||||
mDescriptionText.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mIllustrationNormal.setVisibility(View.VISIBLE);
|
||||
mIllustrationNormal.start();
|
||||
mIllustrationAccessibility.setVisibility(View.INVISIBLE);
|
||||
mDescriptionText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -88,6 +98,7 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|
||||
|
||||
mIllustrationNormal = findViewById(R.id.illustration_normal);
|
||||
mIllustrationAccessibility = findViewById(R.id.illustration_accessibility);
|
||||
mDescriptionText = findViewById(R.id.sud_layout_description);
|
||||
|
||||
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
|
||||
mFooterBarMixin.setSecondaryButton(
|
||||
|
||||
@@ -94,6 +94,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
||||
Log.e(TAG, "Unable to remove face: " + face.getBiometricId()
|
||||
+ " error: " + errMsgId + " " + errString);
|
||||
Toast.makeText(mContext, errString, Toast.LENGTH_SHORT).show();
|
||||
mRemoving = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +132,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
|
||||
mFaceManager.remove(faces.get(0), mUserId, mRemovalCallback);
|
||||
} else {
|
||||
mButton.setEnabled(true);
|
||||
mRemoving = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,27 +17,53 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
public class DarkUIPreferenceController extends TogglePreferenceController {
|
||||
public class DarkUIPreferenceController extends TogglePreferenceController implements
|
||||
LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
public static final String DARK_MODE_PREFS = "dark_mode_prefs";
|
||||
public static final String PREF_DARK_MODE_DIALOG_SEEN = "dark_mode_dialog_seen";
|
||||
public static final int DIALOG_SEEN = 1;
|
||||
|
||||
@VisibleForTesting
|
||||
SwitchPreference mPreference;
|
||||
|
||||
private UiModeManager mUiModeManager;
|
||||
private PowerManager mPowerManager;
|
||||
private Context mContext;
|
||||
|
||||
private Fragment mFragment;
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
updateEnabledStateIfNeeded();
|
||||
}
|
||||
};
|
||||
|
||||
public DarkUIPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mContext = context;
|
||||
mUiModeManager = context.getSystemService(UiModeManager.class);
|
||||
mPowerManager = context.getSystemService(PowerManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +71,18 @@ public class DarkUIPreferenceController extends TogglePreferenceController {
|
||||
return mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
updateEnabledStateIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
final boolean dialogSeen =
|
||||
@@ -67,6 +105,29 @@ public class DarkUIPreferenceController extends TogglePreferenceController {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateEnabledStateIfNeeded() {
|
||||
if (mPreference == null) {
|
||||
return;
|
||||
}
|
||||
boolean isBatterySaver = isPowerSaveMode();
|
||||
mPreference.setEnabled(!isBatterySaver);
|
||||
if (isBatterySaver) {
|
||||
int stringId = mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES
|
||||
? R.string.dark_ui_mode_disabled_summary_dark_theme_on
|
||||
: R.string.dark_ui_mode_disabled_summary_dark_theme_off;
|
||||
mPreference.setSummary(mContext.getString(stringId));
|
||||
} else {
|
||||
mPreference.setSummary(null);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isPowerSaveMode() {
|
||||
return mPowerManager.isPowerSaveMode();
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
void setUiModeManager(UiModeManager uiModeManager) {
|
||||
mUiModeManager = uiModeManager;
|
||||
@@ -76,6 +137,17 @@ public class DarkUIPreferenceController extends TogglePreferenceController {
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mContext.registerReceiver(mReceiver,
|
||||
new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mContext.unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
|
||||
@@ -79,7 +79,6 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
private final PackageManager mPm;
|
||||
private final NotificationBackend mNotificationBackend;
|
||||
private IUsageStatsManager mUsageStatsManager;
|
||||
private final int mUserId;
|
||||
private final IconDrawableFactory mIconDrawableFactory;
|
||||
|
||||
private Calendar mCal;
|
||||
@@ -104,7 +103,6 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
ApplicationsState appState, Fragment host) {
|
||||
super(context);
|
||||
mIconDrawableFactory = IconDrawableFactory.newInstance(context);
|
||||
mUserId = UserHandle.myUserId();
|
||||
mPm = context.getPackageManager();
|
||||
mHost = host;
|
||||
mApplicationsState = appState;
|
||||
@@ -177,7 +175,6 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (events != null) {
|
||||
|
||||
ArrayMap<String, NotifyingApp> aggregatedStats = new ArrayMap<>();
|
||||
|
||||
UsageEvents.Event event = new UsageEvents.Event();
|
||||
@@ -205,7 +202,8 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKey(int userId, String pkg) {
|
||||
@VisibleForTesting
|
||||
static String getKey(int userId, String pkg) {
|
||||
return userId + "|" + pkg;
|
||||
}
|
||||
|
||||
@@ -252,12 +250,13 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
}
|
||||
|
||||
boolean rebindPref = true;
|
||||
NotificationAppPreference pref = appPreferences.remove(pkgName);
|
||||
NotificationAppPreference pref = appPreferences.remove(getKey(app.getUserId(),
|
||||
pkgName));
|
||||
if (pref == null) {
|
||||
pref = new NotificationAppPreference(prefContext);
|
||||
rebindPref = false;
|
||||
}
|
||||
pref.setKey(pkgName);
|
||||
pref.setKey(getKey(app.getUserId(), pkgName));
|
||||
pref.setTitle(appEntry.label);
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
|
||||
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
|
||||
@@ -267,11 +266,11 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
|
||||
args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
|
||||
|
||||
pref.setIntent(new SubSettingLauncher(mHost.getActivity())
|
||||
.setDestination(AppNotificationSettings.class.getName())
|
||||
.setTitleRes(R.string.notifications_title)
|
||||
.setArguments(args)
|
||||
.setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid)))
|
||||
.setSourceMetricsCategory(
|
||||
SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS)
|
||||
.toIntent());
|
||||
@@ -301,11 +300,11 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
int count = 0;
|
||||
for (NotifyingApp app : mApps) {
|
||||
final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(
|
||||
app.getPackage(), mUserId);
|
||||
app.getPackage(), app.getUserId());
|
||||
if (appEntry == null) {
|
||||
continue;
|
||||
}
|
||||
if (!shouldIncludePkgInRecents(app.getPackage())) {
|
||||
if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) {
|
||||
continue;
|
||||
}
|
||||
displayableApps.add(app);
|
||||
@@ -321,14 +320,14 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
/**
|
||||
* Whether or not the app should be included in recent list.
|
||||
*/
|
||||
private boolean shouldIncludePkgInRecents(String pkgName) {
|
||||
private boolean shouldIncludePkgInRecents(String pkgName, int userId) {
|
||||
final Intent launchIntent = new Intent().addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setPackage(pkgName);
|
||||
|
||||
if (mPm.resolveActivity(launchIntent, 0) == null) {
|
||||
// Not visible on launcher -> likely not a user visible app, skip if non-instant.
|
||||
final ApplicationsState.AppEntry appEntry =
|
||||
mApplicationsState.getEntry(pkgName, mUserId);
|
||||
mApplicationsState.getEntry(pkgName, userId);
|
||||
if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
|
||||
Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
|
||||
return false;
|
||||
|
||||
@@ -61,6 +61,16 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
void onSwitchChanged(Switch switchView, boolean isChecked);
|
||||
}
|
||||
|
||||
public interface LabelDelegate {
|
||||
/**
|
||||
* Called to create label and set the title with Accessibility
|
||||
* service name to the textView of switchBar.
|
||||
*
|
||||
* @param isChecked The checked state of switchView.
|
||||
*/
|
||||
String createLabel(boolean isChecked);
|
||||
}
|
||||
|
||||
private static final int[] XML_ATTRIBUTES = {
|
||||
R.attr.switchBarMarginStart,
|
||||
R.attr.switchBarMarginEnd,
|
||||
@@ -90,6 +100,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
private boolean mDisabledByAdmin;
|
||||
private EnforcedAdmin mEnforcedAdmin = null;
|
||||
private String mMetricsTag;
|
||||
private LabelDelegate mLabelDelegate;
|
||||
|
||||
|
||||
public SwitchBar(Context context) {
|
||||
@@ -178,7 +189,11 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
}
|
||||
|
||||
public void setTextViewLabelAndBackground(boolean isChecked) {
|
||||
mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
|
||||
if(mLabelDelegate != null) {
|
||||
mLabel = mLabelDelegate.createLabel(isChecked);
|
||||
} else {
|
||||
mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
|
||||
}
|
||||
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
|
||||
updateText();
|
||||
}
|
||||
@@ -383,4 +398,9 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setLabelDelegate(LabelDelegate labelDelegate) {
|
||||
mLabelDelegate = labelDelegate;
|
||||
setTextViewLabelAndBackground(isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,11 @@ public class UsageGraph extends View {
|
||||
canvas.drawPath(mPath, paint);
|
||||
}
|
||||
|
||||
private void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
|
||||
@VisibleForTesting
|
||||
void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
|
||||
if (localPaths.size() == 0) {
|
||||
return;
|
||||
}
|
||||
mPath.reset();
|
||||
float lastStartX = localPaths.keyAt(0);
|
||||
mPath.moveTo(localPaths.keyAt(0), localPaths.valueAt(0));
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.IPowerManager;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DarkUIPreferenceControllerTest {
|
||||
|
||||
private DarkUIPreferenceController mController;
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private Fragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mController = spy(new DarkUIPreferenceController(mContext, "dark_ui_mode"));
|
||||
mController.setParentFragment(mFragment);
|
||||
mController.mPreference = new SwitchPreference(mContext);
|
||||
mController.onStart();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batterySaverToggles_disabledStateUpdates() {
|
||||
doReturn(true).when(mController).isPowerSaveMode();
|
||||
mController.updateEnabledStateIfNeeded();
|
||||
assertThat(mController.mPreference.isEnabled()).isFalse();
|
||||
|
||||
doReturn(false).when(mController).isPowerSaveMode();
|
||||
mController.updateEnabledStateIfNeeded();
|
||||
assertThat(mController.mPreference.isEnabled()).isTrue();
|
||||
|
||||
doReturn(true).when(mController).isPowerSaveMode();
|
||||
mController.updateEnabledStateIfNeeded();
|
||||
assertThat(mController.mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,6 @@ public class RecentNotifyingAppsPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void display_showRecents() throws Exception {
|
||||
|
||||
List<Event> events = new ArrayList<>();
|
||||
Event app = new Event();
|
||||
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
@@ -262,8 +261,12 @@ public class RecentNotifyingAppsPreferenceControllerTest {
|
||||
ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
|
||||
verify(mCategory, times(2)).addPreference(prefCaptor.capture());
|
||||
List<Preference> prefs = prefCaptor.getAllValues();
|
||||
assertThat(prefs.get(1).getKey()).isEqualTo(app.getPackageName());
|
||||
assertThat(prefs.get(0).getKey()).isEqualTo(app1.getPackageName());
|
||||
assertThat(prefs.get(1).getKey()).isEqualTo(
|
||||
RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
|
||||
app.getPackageName()));
|
||||
assertThat(prefs.get(0).getKey()).isEqualTo(
|
||||
RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
|
||||
app1.getPackageName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,8 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
@@ -177,4 +179,14 @@ public class UsageGraphTest {
|
||||
assertThat(localPaths.keyAt(5)).isEqualTo(1001);
|
||||
assertThat(localPaths.valueAt(5)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawFilledPath_emptyPath_shouldNotCrash() {
|
||||
final Canvas canvas = new Canvas();
|
||||
final SparseIntArray localPaths = new SparseIntArray();
|
||||
final Paint paint = new Paint();
|
||||
|
||||
// Should not crash
|
||||
mGraph.drawFilledPath(canvas, localPaths, paint);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user