Add support for LearnMore option
UsbContaminant dialog no longer uses AlertActivity/AlertController as UI design has been updated to a custom design to support the Learn more option. The CL also incorporates string updates. Bug: 132737150 Test: dumpsys usb add-port "matrix" ufp; dumpsys usb set-contaminant-status "matrix" true Change-Id: I2b27e60e48986e669ef9bfe0239a56430d14a5a2
This commit is contained in:
@@ -3609,7 +3609,7 @@
|
||||
<!-- Message of notification shown when contaminant is detected on the USB port. [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_contaminant_detected_message">USB port is automatically disabled. Tap to learn more.</string>
|
||||
<!-- Title of notification shown when contaminant is no longer detected on the USB port. [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_contaminant_not_detected_title">Safe to use USB port</string>
|
||||
<string name="usb_contaminant_not_detected_title">OK to use USB port</string>
|
||||
<!-- Message of notification shown when contaminant is no longer detected on the USB port. [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_contaminant_not_detected_message">Phone no longer detects liquid or debris.</string>
|
||||
|
||||
|
||||
87
packages/SystemUI/res/layout/contaminant_dialog.xml
Normal file
87
packages/SystemUI/res/layout/contaminant_dialog.xml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/res/layout/alert_dialog.xml
|
||||
**
|
||||
** Copyright 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/parentPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="18dp"
|
||||
android:paddingBottom="18dp"
|
||||
android:textAlignment="center"
|
||||
android:fontFamily="google-sans-medium"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingBottom="24dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp"
|
||||
android:fontFamily="roboto-regular"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@android:drawable/divider_horizontal_bright" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/learnMore"
|
||||
style="@style/USBContaminant.UserAction" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@android:drawable/divider_horizontal_bright" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/enableUsb"
|
||||
style="@style/USBContaminant.UserAction" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@android:drawable/divider_horizontal_bright" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gotIt"
|
||||
style="@style/USBContaminant.UserAction" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -166,7 +166,7 @@
|
||||
<string name="usb_contaminant_title">USB port disabled</string>
|
||||
|
||||
<!-- Message of USB contaminant presence dialog [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_contaminant_message">To protect your device from liquid or debris, the USB port is disabled and won\u2019t detect any accessories.\n\nYou\u2019ll be notified when it\u2019s safe to use the USB port again.</string>
|
||||
<string name="usb_contaminant_message">To protect your device from liquid or debris, the USB port is disabled and won\u2019t detect any accessories.\n\nYou\u2019ll be notified when it\u2019s okay to use the USB port again.</string>
|
||||
|
||||
<!-- Toast for enabling ports from USB contaminant dialog [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_port_enabled">USB port enabled to detect chargers and accessories</string>
|
||||
@@ -174,6 +174,9 @@
|
||||
<!-- Button text to disable contaminant detection [CHAR LIMIT=NONE] -->
|
||||
<string name="usb_disable_contaminant_detection">Enable USB</string>
|
||||
|
||||
<!-- Button text to disable contaminant detection [CHAR LIMIT=NONE] -->
|
||||
<string name="learn_more">Learn more</string>
|
||||
|
||||
<!-- Checkbox label for application compatibility mode ON (zooming app to look like it's running
|
||||
on a phone). [CHAR LIMIT=25] -->
|
||||
<string name="compat_mode_on">Zoom to fill screen</string>
|
||||
|
||||
@@ -572,4 +572,22 @@
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
<item name="android:windowCloseOnTouchOutside">true</item>
|
||||
</style>
|
||||
|
||||
<!-- USB Contaminant dialog -->
|
||||
<style name ="USBContaminant" />
|
||||
|
||||
<style name ="USBContaminant.UserAction">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:fontFamily">roboto-regular</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingTop">16dp</item>
|
||||
<item name="android:paddingRight">24dp</item>
|
||||
<item name="android:paddingBottom">16dp</item>
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:clickable">true</item>
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -16,30 +16,33 @@
|
||||
|
||||
package com.android.systemui.usb;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.hardware.usb.ParcelableUsbPort;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.hardware.usb.UsbPort;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.systemui.R;
|
||||
|
||||
/**
|
||||
* Activity that alerts the user when contaminant is detected on USB port.
|
||||
*/
|
||||
public class UsbContaminantActivity extends AlertActivity
|
||||
implements DialogInterface.OnClickListener {
|
||||
public class UsbContaminantActivity extends Activity implements View.OnClickListener {
|
||||
private static final String TAG = "UsbContaminantActivity";
|
||||
|
||||
private UsbPort mUsbPort;
|
||||
private TextView mLearnMore;
|
||||
private TextView mGotIt;
|
||||
private TextView mEnableUsb;
|
||||
private TextView mTitle;
|
||||
private TextView mMessage;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -47,22 +50,30 @@ public class UsbContaminantActivity extends AlertActivity
|
||||
window.addSystemFlags(WindowManager.LayoutParams
|
||||
.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.contaminant_dialog);
|
||||
|
||||
Intent intent = getIntent();
|
||||
ParcelableUsbPort port = intent.getParcelableExtra(UsbManager.EXTRA_PORT);
|
||||
mUsbPort = port.getUsbPort(getSystemService(UsbManager.class));
|
||||
|
||||
final AlertController.AlertParams ap = mAlertParams;
|
||||
ap.mTitle = getString(R.string.usb_contaminant_title);
|
||||
ap.mMessage = getString(R.string.usb_contaminant_message);
|
||||
ap.mNegativeButtonText = getString(android.R.string.ok);
|
||||
ap.mNeutralButtonText = getString(R.string.usb_disable_contaminant_detection);
|
||||
ap.mNegativeButtonListener = this;
|
||||
ap.mNeutralButtonListener = this;
|
||||
mLearnMore = findViewById(R.id.learnMore);
|
||||
mEnableUsb = findViewById(R.id.enableUsb);
|
||||
mGotIt = findViewById(R.id.gotIt);
|
||||
mTitle = findViewById(R.id.title);
|
||||
mMessage = findViewById(R.id.message);
|
||||
|
||||
setupAlert();
|
||||
mTitle.setText(getString(R.string.usb_contaminant_title));
|
||||
mMessage.setText(getString(R.string.usb_contaminant_message));
|
||||
mEnableUsb.setText(getString(R.string.usb_disable_contaminant_detection));
|
||||
mGotIt.setText(getString(R.string.got_it));
|
||||
mLearnMore.setText(getString(R.string.learn_more));
|
||||
|
||||
mEnableUsb.setOnClickListener(this);
|
||||
mGotIt.setOnClickListener(this);
|
||||
mLearnMore.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,8 +82,8 @@ public class UsbContaminantActivity extends AlertActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == AlertDialog.BUTTON_NEUTRAL) {
|
||||
public void onClick(View v) {
|
||||
if (v == mEnableUsb) {
|
||||
try {
|
||||
mUsbPort.enableContaminantDetection(false);
|
||||
Toast.makeText(this, R.string.usb_port_enabled,
|
||||
@@ -80,6 +91,13 @@ public class UsbContaminantActivity extends AlertActivity
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Unable to notify Usb service", e);
|
||||
}
|
||||
} else if (v == mLearnMore) {
|
||||
final Intent intent = new Intent();
|
||||
intent.setClassName("com.android.settings",
|
||||
"com.android.settings.HelpTrampoline");
|
||||
intent.putExtra(Intent.EXTRA_TEXT,
|
||||
"help_url_usb_contaminant_detected");
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user