Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 775f334f authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Android (Google) Code Review
Browse files

Merge "Add support for LearnMore option" into qt-dev

parents c8a97db0 f603a2c6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3614,7 +3614,7 @@
    <!-- Message of notification shown when contaminant is detected on the USB port. [CHAR LIMIT=NONE] -->
    <!-- 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>
    <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] -->
    <!-- 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] -->
    <!-- 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>
    <string name="usb_contaminant_not_detected_message">Phone no longer detects liquid or debris.</string>


+87 −0
Original line number Original line Diff line number Diff line
<?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>
+4 −1
Original line number Original line Diff line number Diff line
@@ -166,7 +166,7 @@
    <string name="usb_contaminant_title">USB port disabled</string>
    <string name="usb_contaminant_title">USB port disabled</string>


    <!-- Message of USB contaminant presence dialog [CHAR LIMIT=NONE] -->
    <!-- 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] -->
    <!-- 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>
    <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] -->
    <!-- Button text to disable contaminant detection [CHAR LIMIT=NONE] -->
    <string name="usb_disable_contaminant_detection">Enable USB</string>
    <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
    <!-- Checkbox label for application compatibility mode ON (zooming app to look like it's running
         on a phone).  [CHAR LIMIT=25] -->
         on a phone).  [CHAR LIMIT=25] -->
    <string name="compat_mode_on">Zoom to fill screen</string>
    <string name="compat_mode_on">Zoom to fill screen</string>
+18 −0
Original line number Original line Diff line number Diff line
@@ -572,4 +572,22 @@
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:windowCloseOnTouchOutside">true</item>
        <item name="android:windowCloseOnTouchOutside">true</item>
    </style>
    </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>
</resources>
+34 −16
Original line number Original line Diff line number Diff line
@@ -16,30 +16,33 @@


package com.android.systemui.usb;
package com.android.systemui.usb;


import android.app.AlertDialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Intent;
import android.hardware.usb.ParcelableUsbPort;
import android.hardware.usb.ParcelableUsbPort;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPort;
import android.os.Bundle;
import android.os.Bundle;
import android.util.Log;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toast;


import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import com.android.systemui.R;
import com.android.systemui.R;


/**
/**
 * Activity that alerts the user when contaminant is detected on USB port.
 * Activity that alerts the user when contaminant is detected on USB port.
 */
 */
public class UsbContaminantActivity extends AlertActivity
public class UsbContaminantActivity extends Activity implements View.OnClickListener {
                                  implements DialogInterface.OnClickListener {
    private static final String TAG = "UsbContaminantActivity";
    private static final String TAG = "UsbContaminantActivity";


    private UsbPort mUsbPort;
    private UsbPort mUsbPort;
    private TextView mLearnMore;
    private TextView mGotIt;
    private TextView mEnableUsb;
    private TextView mTitle;
    private TextView mMessage;


    @Override
    @Override
    public void onCreate(Bundle icicle) {
    public void onCreate(Bundle icicle) {
@@ -47,22 +50,30 @@ public class UsbContaminantActivity extends AlertActivity
        window.addSystemFlags(WindowManager.LayoutParams
        window.addSystemFlags(WindowManager.LayoutParams
                .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
                .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
        window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
        requestWindowFeature(Window.FEATURE_NO_TITLE);


        super.onCreate(icicle);
        super.onCreate(icicle);
        setContentView(R.layout.contaminant_dialog);


        Intent intent = getIntent();
        Intent intent = getIntent();
        ParcelableUsbPort port = intent.getParcelableExtra(UsbManager.EXTRA_PORT);
        ParcelableUsbPort port = intent.getParcelableExtra(UsbManager.EXTRA_PORT);
        mUsbPort = port.getUsbPort(getSystemService(UsbManager.class));
        mUsbPort = port.getUsbPort(getSystemService(UsbManager.class));


        final AlertController.AlertParams ap = mAlertParams;
        mLearnMore = findViewById(R.id.learnMore);
        ap.mTitle = getString(R.string.usb_contaminant_title);
        mEnableUsb = findViewById(R.id.enableUsb);
        ap.mMessage = getString(R.string.usb_contaminant_message);
        mGotIt = findViewById(R.id.gotIt);
        ap.mNegativeButtonText = getString(android.R.string.ok);
        mTitle = findViewById(R.id.title);
        ap.mNeutralButtonText = getString(R.string.usb_disable_contaminant_detection);
        mMessage = findViewById(R.id.message);
        ap.mNegativeButtonListener = this;
        ap.mNeutralButtonListener = this;


        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
    @Override
@@ -71,8 +82,8 @@ public class UsbContaminantActivity extends AlertActivity
    }
    }


    @Override
    @Override
    public void onClick(DialogInterface dialog, int which) {
    public void onClick(View v) {
        if (which == AlertDialog.BUTTON_NEUTRAL) {
        if (v == mEnableUsb) {
            try {
            try {
                mUsbPort.enableContaminantDetection(false);
                mUsbPort.enableContaminantDetection(false);
                Toast.makeText(this, R.string.usb_port_enabled,
                Toast.makeText(this, R.string.usb_port_enabled,
@@ -80,6 +91,13 @@ public class UsbContaminantActivity extends AlertActivity
            } catch (Exception e) {
            } catch (Exception e) {
                Log.e(TAG, "Unable to notify Usb service", 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();
        finish();
    }
    }