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

Commit 0de040ce authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added autofill options on Developer Options screen."

parents 7fa8953b 9bf591b8
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1119,4 +1119,18 @@
        <item>0</item>
    </string-array>

    <!-- Titles for autofill logging level preference. [CHAR LIMIT=50] -->
    <string-array name="autofill_logging_level_entries">
        <item>Off</item>
        <item>Debug</item>
        <item>Verbose</item>
    </string-array>

    <!-- Values for autofill logging level preference. -->
    <string-array name="autofill_logging_level_values" translatable="false" >
        <item>0</item> <!-- AutofillManager.NO_LOGGING -->
        <item>2</item> <!-- AutofillManager.FLAG_ADD_CLIENT_DEBUG -->
        <item>4</item> <!-- AutofillManager.FLAG_ADD_CLIENT_VERBOSE -->
    </string-array>

</resources>
+18 −0
Original line number Diff line number Diff line
@@ -9864,6 +9864,24 @@
        ]]>
    </string>
    <!-- Preference category for autofill debugging development settings. [CHAR LIMIT=25] -->
    <string name="debug_autofill_category">Autofill</string>
    <!-- UI debug setting: logging level for Android Autofill [CHAR LIMIT=25] -->
    <string name="autofill_logging_level_title">Logging level</string>
    <!-- Title of developer options to set the maximum number of partitions per session [CHAR LIMIT=60]-->
    <string name="autofill_max_partitions">Max partitions</string>
    <!-- Title of developer options to set the maximum number of visible datasets in the autofill UX [CHAR LIMIT=60]-->
    <string name="autofill_max_visible_datasets">Max visible datasets</string>
    <!-- Reset all autofill developer options to their default values.[CHAR_LIMIT=60] -->
    <string name="autofill_reset_developer_options">Reset to default values</string>
    <!-- Toast message shown when autofill_reset_developer_options has been performed. [CHAR_LIMIT=none] -->
    <string name="autofill_reset_developer_options_complete">Autofill developer options have been reset</string>
    <!-- Name of setting for switching device theme [CHAR LIMIT=60] -->
    <string name="device_theme">Device theme</string>
    <!-- Name of default device theme [CHAR LIMIT=60] -->
+25 −0
Original line number Diff line number Diff line
@@ -506,4 +506,29 @@
            android:title="@string/reset_shortcut_manager_throttling" />
    </PreferenceCategory>

    <com.android.settings.development.autofill.AutofillPreferenceCategory
        android:key="debug_autofill_category"
        android:title="@string/debug_autofill_category"
        android:order="1100">

        <ListPreference
            android:key="autofill_logging_level"
            android:title="@string/autofill_logging_level_title"
            android:entries="@array/autofill_logging_level_entries"
            android:entryValues="@array/autofill_logging_level_values" />

        <com.android.settings.development.autofill.AutofillMaxPartitionsPreference
            android:key="autofill_max_partitions"
            android:title="@string/autofill_max_partitions" />

        <com.android.settings.development.autofill.AutofillVisibleDatasetsPreference
            android:key="autofill_visible_datasets"
            android:title="@string/autofill_max_visible_datasets" />

        <Preference
            android:key="autofill_reset_developer_options"
            android:title="@string/autofill_reset_developer_options" />

    </com.android.settings.development.autofill.AutofillPreferenceCategory>

</PreferenceScreen>
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.development.autofill.AutofillLoggingLevelPreferenceController;
import com.android.settings.development.autofill.AutofillResetOptionsPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.widget.SwitchBar;
@@ -466,6 +468,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        controllers.add(new DefaultLaunchPreferenceController(context, "density"));
        controllers.add(new DefaultLaunchPreferenceController(context, "background_check"));
        controllers.add(new DefaultLaunchPreferenceController(context, "inactive_apps"));
        controllers.add(new AutofillLoggingLevelPreferenceController(context));
        controllers.add(new AutofillResetOptionsPreferenceController(context));
        return controllers;
    }

+112 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.development.autofill;

import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings;
import android.text.BidiFormatter;
import android.text.InputType;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Slog;
import android.view.Display;
import android.view.View;
import android.view.autofill.AutofillManager;
import android.widget.EditText;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.CustomEditTextPreferenceCompat;

import java.text.NumberFormat;

/**
 * Base class for Autofill integer properties that are backed by
 * {@link android.provider.Settings.Global}.
 */
abstract class AbstractGlobalSettingsPreference extends CustomEditTextPreferenceCompat {

    private static final String TAG = "AbstractGlobalSettingsPreference";

    private final String mKey;
    private final int mDefaultValue;

    private final AutofillDeveloperSettingsObserver mObserver;

    protected AbstractGlobalSettingsPreference(Context context, AttributeSet attrs,
            String key, int defaultValue) {
        super(context, attrs);

        mKey = key;
        mDefaultValue = defaultValue;
        mObserver = new AutofillDeveloperSettingsObserver(context, () -> updateSummary());
    }

    @Override
    public void onAttached() {
        super.onAttached();

        mObserver.register();
        updateSummary();
    }

    @Override
    public void onDetached() {
        mObserver.unregister();

        super.onDetached();
    }

    private String getCurrentValue() {
        final int value = Settings.Global.getInt(getContext().getContentResolver(),
                mKey, mDefaultValue);

        return Integer.toString(value);
    }

    private void updateSummary() {
        setSummary(getCurrentValue());

    }

    @Override
    protected void onBindDialogView(View view) {
        super.onBindDialogView(view);

        EditText editText = view.findViewById(android.R.id.edit);
        if (editText != null) {
            editText.setInputType(InputType.TYPE_CLASS_NUMBER);
            editText.setText(getCurrentValue());
            Utils.setEditTextCursorPosition(editText);
        }
    }

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        if (positiveResult) {
            final String stringValue = getText();
            int newValue = mDefaultValue;
            try {
                newValue = Integer.parseInt(stringValue);
            } catch (Exception e) {
                Log.e(TAG, "Error converting '" + stringValue + "' to integer. Using "
                        + mDefaultValue + " instead");
            }
            Settings.Global.putInt(getContext().getContentResolver(), mKey, newValue);
        }
    }
}
Loading