Merge changes I69fb6747,I1661f4ad into sc-dev
* changes: Show a bottom sheet when the mic/camera is blocked Add a tv bottom sheet to the SystemUI.
This commit is contained in:
committed by
Android (Google) Code Review
commit
277c8e1b29
@@ -42,4 +42,8 @@
|
||||
|
||||
<!-- Allow SystemUI to show the shutdown dialog -->
|
||||
<bool name="config_showSysuiShutdown">true</bool>
|
||||
|
||||
<!-- Component name of the activity used to inform a user about a sensory being blocked because
|
||||
of privacy settings. -->
|
||||
<string name="config_sensorUseStartedActivity">com.android.systemui/com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity</string>
|
||||
</resources>
|
||||
|
||||
@@ -454,6 +454,14 @@
|
||||
android:finishOnCloseSystemDialogs="true">
|
||||
</activity>
|
||||
|
||||
<!-- started from SensoryPrivacyService -->
|
||||
<activity android:name=".sensorprivacy.television.TvUnblockSensorActivity"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.MANAGE_SENSOR_PRIVACY"
|
||||
android:theme="@style/BottomSheet"
|
||||
android:finishOnCloseSystemDialogs="true">
|
||||
</activity>
|
||||
|
||||
|
||||
<!-- started from UsbDeviceSettingsManager -->
|
||||
<activity android:name=".usb.UsbAccessoryUriActivity"
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<selector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="@dimen/bottom_sheet_button_selection_scaled"
|
||||
android:valueType="floatType"/>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="@dimen/bottom_sheet_button_selection_scaled"
|
||||
android:valueType="floatType"/>
|
||||
</set>
|
||||
</item>
|
||||
<item android:state_focused="false">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:propertyName="scaleX"
|
||||
android:valueFrom="@dimen/bottom_sheet_button_selection_scaled"
|
||||
android:valueTo="1.0"
|
||||
android:valueType="floatType"/>
|
||||
<objectAnimator
|
||||
android:duration="200"
|
||||
android:propertyName="scaleY"
|
||||
android:valueFrom="@dimen/bottom_sheet_button_selection_scaled"
|
||||
android:valueTo="1.0"
|
||||
android:valueType="floatType"/>
|
||||
</set>
|
||||
</item>
|
||||
</selector>
|
||||
23
packages/SystemUI/res/anim/tv_bottom_sheet_enter.xml
Normal file
23
packages/SystemUI/res/anim/tv_bottom_sheet_enter.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:interpolator/decelerate_quint">
|
||||
<translate android:fromYDelta="100%"
|
||||
android:toYDelta="0"
|
||||
android:duration="900"/>
|
||||
</set>
|
||||
23
packages/SystemUI/res/anim/tv_bottom_sheet_exit.xml
Normal file
23
packages/SystemUI/res/anim/tv_bottom_sheet_exit.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@android:interpolator/decelerate_quint">
|
||||
<translate android:fromYDelta="0"
|
||||
android:toYDelta="100%"
|
||||
android:duration="500"/>
|
||||
</set>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"
|
||||
android:color="@color/bottom_sheet_button_background_color_focused"/>
|
||||
<item android:color="@color/bottom_sheet_button_background_color_unfocused"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true"
|
||||
android:color="@color/bottom_sheet_button_text_color_focused"/>
|
||||
<item android:color="@color/bottom_sheet_button_text_color_unfocused"/>
|
||||
</selector>
|
||||
20
packages/SystemUI/res/drawable/bottom_sheet_background.xml
Normal file
20
packages/SystemUI/res/drawable/bottom_sheet_background.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/bottom_sheet_background_color"/>
|
||||
<corners android:radius="@dimen/bottom_sheet_corner_radius"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/bottom_sheet_background_color_with_blur"/>
|
||||
<corners android:radius="@dimen/bottom_sheet_corner_radius"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/bottom_sheet_button_background_color"/>
|
||||
<corners android:radius="@dimen/bottom_sheet_button_corner_radius"/>
|
||||
</shape>
|
||||
87
packages/SystemUI/res/layout/tv_bottom_sheet.xml
Normal file
87
packages/SystemUI/res/layout/tv_bottom_sheet.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bottom_sheet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:minHeight="@dimen/bottom_sheet_min_height"
|
||||
android:paddingHorizontal="@dimen/bottom_sheet_padding_horizontal"
|
||||
android:paddingVertical="@dimen/bottom_sheet_padding_vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="80dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/bottom_sheet_icon"
|
||||
android:layout_width="@dimen/bottom_sheet_icon_size"
|
||||
android:layout_height="@dimen/bottom_sheet_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:tint="@color/bottom_sheet_icon_color"/>
|
||||
<ImageView
|
||||
android:id="@+id/bottom_sheet_second_icon"
|
||||
android:layout_width="@dimen/bottom_sheet_icon_size"
|
||||
android:layout_height="@dimen/bottom_sheet_icon_size"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:tint="@color/bottom_sheet_icon_color"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_padding_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_title_margin_bottom"
|
||||
android:textAppearance="@style/BottomSheet.TitleText"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_body"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_details_margin_bottom"
|
||||
android:textAppearance="@style/BottomSheet.BodyText" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="@dimen/bottom_sheet_actions_width"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
<Button
|
||||
android:id="@+id/bottom_sheet_positive_button"
|
||||
style="@style/BottomSheet.ActionItem" />
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/bottom_sheet_actions_spacing" />
|
||||
<Button
|
||||
android:id="@+id/bottom_sheet_negative_button"
|
||||
style="@style/BottomSheet.ActionItem" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -19,4 +19,19 @@
|
||||
<resources>
|
||||
<color name="volume_dialog_background_color">#E61F232B</color>
|
||||
<color name="volume_dialog_background_color_above_blur">#C71F232B</color>
|
||||
|
||||
<color name="bottom_sheet_icon_color">#D2E3FC</color>
|
||||
|
||||
<color name="bottom_sheet_title_color">#E8F0FE</color>
|
||||
<color name="bottom_sheet_body_color">#D2E3FC</color>
|
||||
|
||||
<color name="bottom_sheet_background_color">#1F232C</color>
|
||||
<color name="bottom_sheet_background_color_with_blur">#AA1A2734</color>
|
||||
|
||||
<color name="bottom_sheet_button_background_color_focused">#E8F0FE</color>
|
||||
<color name="bottom_sheet_button_background_color_unfocused">#0FE8EAED</color>
|
||||
|
||||
<color name="bottom_sheet_button_text_color_focused">#DB202124</color>
|
||||
<color name="bottom_sheet_button_text_color_unfocused">#B5E8EAED</color>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -21,4 +21,27 @@
|
||||
<dimen name="privacy_chip_icon_margin">3dp</dimen>
|
||||
<dimen name="privacy_chip_icon_padding">8dp</dimen>
|
||||
<dimen name="privacy_chip_icon_size">13dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_padding_horizontal">32dp</dimen>
|
||||
<dimen name="bottom_sheet_padding_vertical">24dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_icon_size">42dp</dimen>
|
||||
<dimen name="bottom_sheet_icon_margin">8dp</dimen>
|
||||
<dimen name="bottom_sheet_title_margin_bottom">18dp</dimen>
|
||||
<dimen name="bottom_sheet_details_margin_bottom">8dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_actions_width">296dp</dimen>
|
||||
<dimen name="bottom_sheet_actions_spacing">12dp</dimen>
|
||||
<item name="bottom_sheet_button_selection_scaled" format="float" type="dimen">1.1</item>
|
||||
<dimen name="bottom_sheet_button_width">232dp</dimen>
|
||||
<dimen name="bottom_sheet_button_padding_horizontal">20dp</dimen>
|
||||
<dimen name="bottom_sheet_button_padding_vertical">16dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_corner_radius">24dp</dimen>
|
||||
<dimen name="bottom_sheet_button_corner_radius">10dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_min_height">208dp</dimen>
|
||||
<dimen name="bottom_sheet_margin">24dp</dimen>
|
||||
<dimen name="bottom_sheet_background_blur_radius">120dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -28,4 +28,34 @@
|
||||
<item name="android:textColorPrimaryInverse">@color/tv_volume_dialog_accent</item>
|
||||
<item name="android:dialogCornerRadius">@dimen/volume_dialog_panel_width_half</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomSheet" parent="Theme.Leanback">
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:backgroundDimAmount">0.2</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomSheet.TitleText">
|
||||
<item name="android:textSize">28sp</item>
|
||||
<item name="android:textColor">@color/bottom_sheet_title_color</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomSheet.BodyText">
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:textColor">@color/bottom_sheet_body_color</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomSheet.ActionItem">
|
||||
<item name="android:layout_width">@dimen/bottom_sheet_button_width</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:gravity">left|center_vertical</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:textColor">@color/bottom_sheet_button_text_color</item>
|
||||
<item name="android:background">@drawable/bottom_sheet_button_background</item>
|
||||
<item name="android:paddingHorizontal">@dimen/bottom_sheet_button_padding_horizontal</item>
|
||||
<item name="android:paddingVertical">@dimen/bottom_sheet_button_padding_vertical</item>
|
||||
<item name="android:stateListAnimator">@anim/tv_bottom_sheet_button_state_list_animator</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.android.systemui.people.widget.LaunchConversationActivity;
|
||||
import com.android.systemui.screenrecord.ScreenRecordDialog;
|
||||
import com.android.systemui.screenshot.LongScreenshotActivity;
|
||||
import com.android.systemui.sensorprivacy.SensorUseStartedActivity;
|
||||
import com.android.systemui.sensorprivacy.television.TvUnblockSensorActivity;
|
||||
import com.android.systemui.settings.brightness.BrightnessDialog;
|
||||
import com.android.systemui.statusbar.tv.notifications.TvNotificationPanelActivity;
|
||||
import com.android.systemui.tuner.TunerActivity;
|
||||
@@ -120,4 +121,10 @@ public abstract class DefaultActivityBinder {
|
||||
@IntoMap
|
||||
@ClassKey(SensorUseStartedActivity.class)
|
||||
public abstract Activity bindSensorUseStartedActivity(SensorUseStartedActivity activity);
|
||||
|
||||
/** Inject into TvUnblockSensorActivity. */
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(TvUnblockSensorActivity.class)
|
||||
public abstract Activity bindTvUnblockSensorActivity(TvUnblockSensorActivity activity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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.systemui.sensorprivacy.television;
|
||||
|
||||
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
|
||||
import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
|
||||
|
||||
import android.hardware.SensorPrivacyManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController;
|
||||
import com.android.systemui.tv.TvBottomSheetActivity;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Bottom sheet that is shown when the camera/mic sensors are blocked by the global toggle and
|
||||
* allows the user to re-enable them.
|
||||
*/
|
||||
public class TvUnblockSensorActivity extends TvBottomSheetActivity {
|
||||
|
||||
private static final String TAG = TvUnblockSensorActivity.class.getSimpleName();
|
||||
|
||||
private static final int ALL_SENSORS = Integer.MAX_VALUE;
|
||||
private int mSensor = -1;
|
||||
|
||||
private final IndividualSensorPrivacyController mSensorPrivacyController;
|
||||
private IndividualSensorPrivacyController.Callback mSensorPrivacyCallback;
|
||||
|
||||
@Inject
|
||||
public TvUnblockSensorActivity(
|
||||
IndividualSensorPrivacyController individualSensorPrivacyController) {
|
||||
mSensorPrivacyController = individualSensorPrivacyController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean allSensors = getIntent().getBooleanExtra(SensorPrivacyManager.EXTRA_ALL_SENSORS,
|
||||
false);
|
||||
if (allSensors) {
|
||||
mSensor = ALL_SENSORS;
|
||||
} else {
|
||||
mSensor = getIntent().getIntExtra(SensorPrivacyManager.EXTRA_SENSOR, -1);
|
||||
}
|
||||
|
||||
if (mSensor == -1) {
|
||||
Log.v(TAG, "Invalid extras");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mSensorPrivacyCallback = (sensor, blocked) -> {
|
||||
if (mSensor == ALL_SENSORS) {
|
||||
if (!mSensorPrivacyController.isSensorBlocked(CAMERA)
|
||||
&& !mSensorPrivacyController.isSensorBlocked(MICROPHONE)) {
|
||||
finish();
|
||||
}
|
||||
} else if (this.mSensor == sensor && !blocked) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
initUI();
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
TextView title = findViewById(R.id.bottom_sheet_title);
|
||||
TextView content = findViewById(R.id.bottom_sheet_body);
|
||||
ImageView icon = findViewById(R.id.bottom_sheet_icon);
|
||||
// mic icon if both icons are shown
|
||||
ImageView secondIcon = findViewById(R.id.bottom_sheet_second_icon);
|
||||
Button unblockButton = findViewById(R.id.bottom_sheet_positive_button);
|
||||
Button cancelButton = findViewById(R.id.bottom_sheet_negative_button);
|
||||
|
||||
switch (mSensor) {
|
||||
case MICROPHONE:
|
||||
title.setText(R.string.sensor_privacy_start_use_mic_dialog_title);
|
||||
content.setText(R.string.sensor_privacy_start_use_mic_dialog_content);
|
||||
icon.setImageResource(com.android.internal.R.drawable.perm_group_microphone);
|
||||
secondIcon.setVisibility(View.GONE);
|
||||
break;
|
||||
case CAMERA:
|
||||
title.setText(R.string.sensor_privacy_start_use_camera_dialog_title);
|
||||
content.setText(R.string.sensor_privacy_start_use_camera_dialog_content);
|
||||
icon.setImageResource(com.android.internal.R.drawable.perm_group_camera);
|
||||
secondIcon.setVisibility(View.GONE);
|
||||
break;
|
||||
case ALL_SENSORS:
|
||||
default:
|
||||
title.setText(R.string.sensor_privacy_start_use_mic_camera_dialog_title);
|
||||
content.setText(R.string.sensor_privacy_start_use_mic_camera_dialog_content);
|
||||
icon.setImageResource(com.android.internal.R.drawable.perm_group_camera);
|
||||
secondIcon.setImageResource(com.android.internal.R.drawable.perm_group_microphone);
|
||||
break;
|
||||
}
|
||||
unblockButton.setText(
|
||||
com.android.internal.R.string.sensor_privacy_start_use_dialog_turn_on_button);
|
||||
unblockButton.setOnClickListener(v -> {
|
||||
if (mSensor == ALL_SENSORS) {
|
||||
mSensorPrivacyController.setSensorBlocked(CAMERA, false);
|
||||
mSensorPrivacyController.setSensorBlocked(MICROPHONE, false);
|
||||
} else {
|
||||
mSensorPrivacyController.setSensorBlocked(mSensor, false);
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setText(android.R.string.cancel);
|
||||
cancelButton.setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mSensorPrivacyController.addCallback(mSensorPrivacyCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mSensorPrivacyController.removeCallback(mSensorPrivacyCallback);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.systemui.tv;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Generic bottom sheet with up to two icons in the beginning and two buttons.
|
||||
*/
|
||||
public abstract class TvBottomSheetActivity extends Activity {
|
||||
|
||||
private static final String TAG = TvBottomSheetActivity.class.getSimpleName();
|
||||
private Drawable mBackgroundWithBlur;
|
||||
private Drawable mBackgroundWithoutBlur;
|
||||
|
||||
private final Consumer<Boolean> mBlurConsumer = this::onBlurChanged;
|
||||
|
||||
private void onBlurChanged(boolean enabled) {
|
||||
Log.v(TAG, "blur enabled: " + enabled);
|
||||
getWindow().setBackgroundDrawable(enabled ? mBackgroundWithBlur : mBackgroundWithoutBlur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.tv_bottom_sheet);
|
||||
|
||||
overridePendingTransition(R.anim.tv_bottom_sheet_enter, 0);
|
||||
|
||||
mBackgroundWithBlur = getResources()
|
||||
.getDrawable(R.drawable.bottom_sheet_background_with_blur);
|
||||
mBackgroundWithoutBlur = getResources().getDrawable(R.drawable.bottom_sheet_background);
|
||||
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
int screenWidth = metrics.widthPixels;
|
||||
int screenHeight = metrics.heightPixels;
|
||||
int marginPx = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_margin);
|
||||
|
||||
WindowManager.LayoutParams windowParams = getWindow().getAttributes();
|
||||
windowParams.width = screenWidth - marginPx * 2;
|
||||
windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
windowParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||
windowParams.horizontalMargin = 0f;
|
||||
windowParams.verticalMargin = (float) marginPx / screenHeight;
|
||||
windowParams.format = PixelFormat.TRANSPARENT;
|
||||
windowParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
||||
windowParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
windowParams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
|
||||
getWindow().setAttributes(windowParams);
|
||||
getWindow().setElevation(getWindow().getElevation() + 5);
|
||||
getWindow().setBackgroundBlurRadius(getResources().getDimensionPixelSize(
|
||||
R.dimen.bottom_sheet_background_blur_radius));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
getWindowManager().addCrossWindowBlurEnabledListener(mBlurConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
getWindowManager().removeCrossWindowBlurEnabledListener(mBlurConsumer);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(0, R.anim.tv_bottom_sheet_exit);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user