Merge "Fix crash for DefaultSubscriptionController" into tm-dev
diff --git a/res/layout/wifi_add_network_view.xml b/res/layout/wifi_add_network_view.xml
index d698adf..480d597 100644
--- a/res/layout/wifi_add_network_view.xml
+++ b/res/layout/wifi_add_network_view.xml
@@ -18,7 +18,8 @@
 <androidx.core.widget.NestedScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="wrap_content"
+    android:fitsSystemWindows="true">
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
diff --git a/res/xml/accessibility_text_reading_options.xml b/res/xml/accessibility_text_reading_options.xml
index 7fd5ff9..513920b 100644
--- a/res/xml/accessibility_text_reading_options.xml
+++ b/res/xml/accessibility_text_reading_options.xml
@@ -27,7 +27,6 @@
 
     <com.android.settings.widget.LabeledSeekBarPreference
         android:key="font_size"
-        android:selectable="true"
         android:summary="@string/short_summary_font_size"
         android:title="@string/title_font_size"
         settings:iconEnd="@drawable/ic_add_24dp"
@@ -38,7 +37,6 @@
 
     <com.android.settings.widget.LabeledSeekBarPreference
         android:key="display_size"
-        android:selectable="true"
         android:summary="@string/screen_zoom_short_summary"
         android:title="@string/screen_zoom_title"
         settings:iconEnd="@drawable/ic_add_24dp"
diff --git a/res/xml/gesture_navigation_settings.xml b/res/xml/gesture_navigation_settings.xml
index 09bb870..022583c 100644
--- a/res/xml/gesture_navigation_settings.xml
+++ b/res/xml/gesture_navigation_settings.xml
@@ -46,7 +46,6 @@
             android:key="gesture_left_back_sensitivity"
             android:title="@string/left_edge"
             android:max="2"
-            android:selectable="true"
             settings:textStart="@string/low_label"
             settings:textEnd="@string/high_label"/>
 
@@ -54,7 +53,6 @@
             android:key="gesture_right_back_sensitivity"
             android:title="@string/right_edge"
             android:max="2"
-            android:selectable="true"
             settings:textStart="@string/low_label"
             settings:textEnd="@string/high_label"/>
     </PreferenceCategory>
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
index 864cf1b..e5e2daa 100644
--- a/res/xml/power_menu_settings.xml
+++ b/res/xml/power_menu_settings.xml
@@ -36,7 +36,6 @@
         android:key="gesture_power_menu_long_press_for_assist_sensitivity"
         android:title="@string/power_menu_long_press_for_assist_sensitivity_title"
         android:summary="@string/power_menu_long_press_for_assist_sensitivity_summary"
-        android:selectable="true"
         settings:textStart="@string/power_menu_long_press_for_assist_sensitivity_low_label"
         settings:textEnd="@string/power_menu_long_press_for_assist_sensitivity_high_label"
         settings:controller="com.android.settings.gestures.LongPressPowerSensitivityPreferenceController"
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 09000bf..80c9ec6 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -185,9 +185,9 @@
                             && ActivityEmbeddingUtils.isEmbeddingActivityEnabled(mContext)) {
                         // Highlight the preference whenever it's clicked
                         final TopLevelSettings topLevelSettings = (TopLevelSettings) fragment;
-                        topLevelSettings.setHighlightPreferenceKey(key);
                         highlightMixin = topLevelSettings.getHighlightMixin();
                         isDuplicateClick = topLevelSettings.isDuplicateClick(preference);
+                        topLevelSettings.setHighlightPreferenceKey(key);
                     }
                     launchIntentOrSelectProfile(activity, tile, intent, sourceMetricsCategory,
                             highlightMixin, isDuplicateClick);
diff --git a/src/com/android/settings/widget/LabeledSeekBarPreference.java b/src/com/android/settings/widget/LabeledSeekBarPreference.java
index 3e09523..5d10116 100644
--- a/src/com/android/settings/widget/LabeledSeekBarPreference.java
+++ b/src/com/android/settings/widget/LabeledSeekBarPreference.java
@@ -26,12 +26,12 @@
 import android.widget.SeekBar;
 import android.widget.TextView;
 
-import androidx.annotation.Nullable;
 import androidx.core.content.res.TypedArrayUtils;
 import androidx.preference.PreferenceViewHolder;
 
 import com.android.internal.util.Preconditions;
 import com.android.settings.R;
+import com.android.settings.Utils;
 
 /**
  * A labeled {@link SeekBarPreference} with left and right text label, icon label, or both.
@@ -61,8 +61,6 @@
     private final int mIconStartContentDescriptionId;
     private final int mIconEndContentDescriptionId;
     private OnPreferenceChangeListener mStopListener;
-    @Nullable
-    private CharSequence mSummary;
     private SeekBar.OnSeekBarChangeListener mSeekBarChangeListener;
 
     public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
@@ -97,8 +95,6 @@
         Preconditions.checkArgument(!(mIconEndContentDescriptionId != 0 && mIconEndId == 0),
                 "The resource of the iconEnd attribute may be invalid or not set, "
                         + "you should set the iconEnd attribute and have the valid resource.");
-
-        mSummary = styledAttrs.getText(R.styleable.Preference_android_summary);
         styledAttrs.recycle();
     }
 
@@ -112,6 +108,17 @@
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
 
+        final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
+        boolean isSummaryVisible = false;
+        if (summaryView != null) {
+            isSummaryVisible = (summaryView.getVisibility() == View.VISIBLE);
+        }
+        final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
+        if (titleView != null && !isSelectable() && isEnabled() && isSummaryVisible) {
+            titleView.setTextColor(
+                    Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary));
+        }
+
         final TextView startText = (TextView) holder.findViewById(android.R.id.text1);
         if (mTextStartId > 0) {
             startText.setText(mTextStartId);
@@ -132,15 +139,6 @@
             seekBar.setTickMark(tickMark);
         }
 
-        final TextView summary = (TextView) holder.findViewById(android.R.id.summary);
-        if (mSummary != null) {
-            summary.setText(mSummary);
-            summary.setVisibility(View.VISIBLE);
-        } else {
-            summary.setText(null);
-            summary.setVisibility(View.GONE);
-        }
-
         final ViewGroup iconStartFrame = (ViewGroup) holder.findViewById(R.id.icon_start_frame);
         final ImageView iconStartView = (ImageView) holder.findViewById(R.id.icon_start);
         updateIconStartIfNeeded(iconStartFrame, iconStartView, seekBar);
@@ -188,25 +186,6 @@
         notifyChanged();
     }
 
-    @Override
-    public void setSummary(CharSequence summary) {
-        super.setSummary(summary);
-        mSummary = summary;
-        notifyChanged();
-    }
-
-    @Override
-    public void setSummary(int summaryResId) {
-        super.setSummary(summaryResId);
-        mSummary = getContext().getText(summaryResId);
-        notifyChanged();
-    }
-
-    @Override
-    public CharSequence getSummary() {
-        return mSummary;
-    }
-
     public void setOnSeekBarChangeListener(SeekBar.OnSeekBarChangeListener seekBarChangeListener) {
         mSeekBarChangeListener = seekBarChangeListener;
     }
diff --git a/src/com/android/settings/widget/SeekBarPreference.java b/src/com/android/settings/widget/SeekBarPreference.java
index 9f9bc9f..e4a37e3 100644
--- a/src/com/android/settings/widget/SeekBarPreference.java
+++ b/src/com/android/settings/widget/SeekBarPreference.java
@@ -82,12 +82,7 @@
                 com.android.internal.R.layout.preference_widget_seekbar);
         a.recycle();
 
-        a = context.obtainStyledAttributes(
-                attrs, com.android.internal.R.styleable.Preference, defStyleAttr, defStyleRes);
-        final boolean isSelectable = a.getBoolean(
-                com.android.settings.R.styleable.Preference_android_selectable, false);
-        setSelectable(isSelectable);
-        a.recycle();
+        setSelectable(false);
 
         setLayoutResource(layoutResId);
     }
@@ -175,11 +170,6 @@
     }
 
     @Override
-    public CharSequence getSummary() {
-        return null;
-    }
-
-    @Override
     protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
         setProgress(restoreValue ? getPersistedInt(mProgress)
                 : (Integer) defaultValue);
diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java
index 01d5ef1..47a027d 100644
--- a/src/com/android/settings/wifi/AddNetworkFragment.java
+++ b/src/com/android/settings/wifi/AddNetworkFragment.java
@@ -24,6 +24,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.widget.Button;
 import android.widget.ImageButton;
 import android.widget.TextView;
@@ -82,6 +83,10 @@
         ssidScannerButton.setOnClickListener(this);
         mUIController = new WifiConfigController2(this, rootView, null, getMode());
 
+        // Resize the layout when keyboard opens.
+        getActivity().getWindow().setSoftInputMode(
+                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+
         return rootView;
     }
 
diff --git a/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java
index 469ca1d..29451bf 100644
--- a/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java
+++ b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java
@@ -31,6 +31,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.widget.Button;
 
 import androidx.annotation.VisibleForTesting;
@@ -124,6 +125,10 @@
             actionBar.setDisplayShowHomeEnabled(false);
         }
 
+        // Resize the layout when keyboard opens.
+        getActivity().getWindow().setSoftInputMode(
+                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+
         return rootView;
     }