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

Commit 838cc252 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update the required or optional styles of EditText in VPN settings" into main

parents 2380c5d1 e82b0b2e
Loading
Loading
Loading
Loading
+19 −35
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:theme="@style/Theme.Material3.DynamicColors.DayNight"
    android:theme="@style/Theme.Network"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
@@ -49,13 +49,12 @@
                    android:visibility="gone">

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/vpn_label"
                    style="@style/vpn_input_label"
                    android:id="@+id/name_layout"
                    android:hint="@string/vpn_name"
                    app:endIconMode="clear_text"
                    app:helperTextEnabled="true"
                    app:helperText="@string/vpn_required"
                    app:errorEnabled="true">
                    app:helperText="@string/vpn_field_required">
                    <com.google.android.material.textfield.TextInputEditText
                        style="@style/vpn_value"
                        android:id="@+id/name"
@@ -71,13 +70,12 @@
                        android:entries="@array/vpn_types"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/vpn_label"
                    style="@style/vpn_input_label"
                    android:id="@+id/server_layout"
                    android:hint="@string/vpn_server"
                    app:endIconMode="clear_text"
                    app:helperTextEnabled="true"
                    app:helperText="@string/vpn_required"
                    app:errorEnabled="true">
                    app:helperText="@string/vpn_field_required">
                    <com.google.android.material.textfield.TextInputEditText
                        style="@style/vpn_value"
                        android:id="@+id/server"/>
@@ -89,13 +87,12 @@
                        android:orientation="vertical"
                        android:visibility="gone">
                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/vpn_label"
                        style="@style/vpn_input_label"
                        android:id="@+id/ipsec_identifier_layout"
                        android:hint="@string/vpn_ipsec_identifier"
                        app:endIconMode="clear_text"
                        app:helperTextEnabled="true"
                        app:helperText="@string/vpn_required"
                        app:errorEnabled="true">
                        app:helperText="@string/vpn_field_required">
                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/vpn_value"
                            android:id="@+id/ipsec_identifier"/>
@@ -108,13 +105,12 @@
                        android:orientation="vertical"
                        android:visibility="gone">
                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/vpn_label"
                        style="@style/vpn_input_label"
                        android:id="@+id/ipsec_secret_layout"
                        android:hint="@string/vpn_ipsec_secret"
                        app:endIconMode="password_toggle"
                        app:helperTextEnabled="true"
                        app:helperText="@string/vpn_required"
                        app:errorEnabled="true">
                        app:helperText="@string/vpn_field_required">
                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/vpn_value"
                            android:id="@+id/ipsec_secret"
@@ -184,13 +180,10 @@
                    android:visibility="gone" >

                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/vpn_label"
                        style="@style/vpn_input_label"
                        android:id="@+id/vpn_proxy_host_layout"
                        android:hint="@string/proxy_hostname_label"
                        app:endIconMode="clear_text"
                        app:helperTextEnabled="true"
                        app:helperText="@string/vpn_optional"
                        app:errorEnabled="true">
                        app:endIconMode="clear_text">
                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/vpn_value"
                            android:id="@+id/vpn_proxy_host"
@@ -198,13 +191,10 @@
                    </com.google.android.material.textfield.TextInputLayout>

                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/vpn_label"
                        style="@style/vpn_input_label"
                        android:id="@+id/vpn_proxy_port_layout"
                        android:hint="@string/proxy_port_label"
                        app:endIconMode="clear_text"
                        app:helperTextEnabled="true"
                        app:helperText="@string/vpn_optional"
                        app:errorEnabled="true">
                        app:endIconMode="clear_text">
                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/vpn_value"
                            android:id="@+id/vpn_proxy_port"
@@ -219,26 +209,20 @@
                    android:orientation="vertical">

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/vpn_label"
                    style="@style/vpn_input_label"
                    android:id="@+id/username_layout"
                    android:hint="@string/vpn_username"
                    app:endIconMode="clear_text"
                    app:helperTextEnabled="true"
                    app:helperText="@string/vpn_optional"
                    app:errorEnabled="true">
                    android:hint="@string/vpn_username_optional"
                    app:endIconMode="clear_text">
                    <com.google.android.material.textfield.TextInputEditText
                        style="@style/vpn_value"
                        android:id="@+id/username"/>
                </com.google.android.material.textfield.TextInputLayout>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/vpn_label"
                    style="@style/vpn_input_label"
                    android:id="@+id/password_layout"
                    android:hint="@string/vpn_password"
                    app:endIconMode="password_toggle"
                    app:helperTextEnabled="true"
                    app:helperText="@string/vpn_optional"
                    app:errorEnabled="true">
                    android:hint="@string/vpn_password_optional"
                    app:endIconMode="password_toggle">
                    <com.google.android.material.textfield.TextInputEditText
                        style="@style/vpn_value"
                        android:id="@+id/password"
+15 −14
Original line number Diff line number Diff line
@@ -364,7 +364,7 @@
    <!-- HTTP proxy settings. Button to clear the proxy box. -->
    <string name="proxy_clear_text">Clear</string>
    <!-- HTTP proxy settings. The port number label. -->
    <string name="proxy_port_label">Proxy port</string>
    <string name="proxy_port_label">Proxy port (optional)</string>
    <!-- HTTP proxy settings. The exclusion list label. -->
    <string name="proxy_exclusionlist_label">Bypass proxy for</string>
    <!-- HTTP proxy settings. The button to restore the defaults. -->
@@ -372,7 +372,7 @@
    <!-- HTTP proxy settings. The button to save. -->
    <string name="proxy_action_text">Done</string>
    <!-- HTTP proxy settings. The text field for the hostname -->
    <string name="proxy_hostname_label">Proxy hostname</string>
    <string name="proxy_hostname_label">Proxy hostname (optional)</string>
    <!-- HTTP proxy settings. Title if there is an error-->
    <string name="proxy_error">Attention</string>
    <!-- HTTP proxy settings. Button to get rid of error box-->
@@ -7262,15 +7262,15 @@ Data usage charges may apply.</string>
    <string name="data_usage_metered_yes">Metered</string>
    <!-- Input label for the name of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_name">Name</string>
    <string name="vpn_name">Name*</string>
    <!-- Input label for the type of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_type">Type</string>
    <!-- Input label for the server address of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_server">Server address</string>
    <string name="vpn_server">Server address*</string>
    <!-- Input label for the IPSec identifier of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_ipsec_identifier">IPSec identifier</string>
    <string name="vpn_ipsec_identifier">IPSec identifier*</string>
    <!-- Input label for the IPSec pre-shared key of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_ipsec_secret">IPSec pre-shared key</string>
    <string name="vpn_ipsec_secret">IPSec pre-shared key*</string>
    <!-- Selection label for the IPSec user certificate of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_ipsec_user_cert">IPSec user certificate</string>
    <!-- Selection label for the IPSec CA certificate of a VPN profile. [CHAR LIMIT=40] -->
@@ -7279,10 +7279,14 @@ Data usage charges may apply.</string>
    <string name="vpn_ipsec_server_cert">IPSec server certificate</string>
    <!-- Checkbox label to show advanced options of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_show_options">Show advanced options</string>
    <!-- Input label for the username of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_username">Username</string>
    <!-- Input label for the password of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_password">Password</string>
    <!-- Input label for the optional username of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_username_optional">Username (optional)</string>
    <!-- Input label for the optional password of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_password_optional">Password (optional)</string>
    <!-- Input label for the required username of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_username_required">Username*</string>
    <!-- Input label for the required password of a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_password_required">Password*</string>
    <!-- Checkbox label to save the username and the password in a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_save_login">Save account information</string>
    <!-- Hint for not using an optional feature in a VPN profile. [CHAR LIMIT=40] -->
@@ -7295,12 +7299,9 @@ Data usage charges may apply.</string>
        generic error. [CHAR LIMIT=120] -->
    <string name="vpn_always_on_invalid_reason_other">The information entered doesn\'t support
        always-on VPN</string>
    <!-- Hint for an optional field in a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_optional">(optional)</string>
    <!-- Hint for a required field in a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_required">(required)</string>
    <!-- Error message displayed below the VPN EditText when the filed is required. [CHAR LIMIT=NONE] -->
    <string name="vpn_field_required">The field is required</string>
    <string name="vpn_field_required">*required</string>
    <!-- Button label to cancel changing a VPN profile. [CHAR LIMIT=40] -->
    <string name="vpn_cancel">Cancel</string>
+4 −0
Original line number Diff line number Diff line
@@ -207,6 +207,10 @@
        <item name="android:textColorHint">?android:attr/textColorSecondary</item>
    </style>

    <style name="vpn_input_label" parent="vpn_label">
        <item name="android:paddingBottom">8dp</item>
    </style>

    <style name="vpn_warning">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
+4 −3
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
    private TextInputGroup mServerInput;
    private TextInputGroup mUsernameInput;
    private TextInputGroup mPasswordInput;
    private TextView mPassword;
    private Spinner mProxySettings;
    private TextView mProxyHost;
    private TextView mProxyPort;
@@ -211,8 +210,10 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
            setTitle(context.getString(R.string.vpn_connect_to, mProfile.name));

            setUsernamePasswordVisibility(mProfile.type);
            mUsernameInput.setHelperText(context.getString(R.string.vpn_required));
            mPasswordInput.setHelperText(context.getString(R.string.vpn_required));
            mUsernameInput.setLabel(context.getString(R.string.vpn_username_required));
            mUsernameInput.setHelperText(context.getString(R.string.vpn_field_required));
            mPasswordInput.setLabel(context.getString(R.string.vpn_password_required));
            mPasswordInput.setHelperText(context.getString(R.string.vpn_field_required));

            // Create a button to connect the network.
            setButton(DialogInterface.BUTTON_POSITIVE,
+7 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ open class TextInputGroup(
        editText.addTextChangedListener(watcher)
    }

    var label: String
        get() = layout.hint?.toString() ?: ""
        set(value) {
            layout.setHint(value)
        }

    var text: String
        get() = editText.text?.toString() ?: ""
        set(value) {
@@ -75,6 +81,7 @@ open class TextInputGroup(
        get() = layout.error?.toString() ?: ""
        set(value) {
            layout.setError(value)
            if (value.isEmpty()) layout.isErrorEnabled = false
        }

    open fun validate(): Boolean {