Files
app_Settings/src/com/android/settings/wifi/WifiDetailPreference.java
Lorenzo Colitti 0bde06cd59 Reduce jank in the wifi detail status page.
Currently, when anything changes, the wifi detail status page
removes and then redraws all IP address information. This causes
the whole screen to flicker. Instead, only add and remove things
when they actually change.

In order to do this, convert the IPv6 addresses from a list of
Preference objects to a single newline-separated text field.
This removes the need to keep track of addresses as they are
added and deleted, and also looks a bit better.

Also, minor correctness fixes:
- Get the gateway from the default route, not from the last route
  with a non-null gateway.
- Get the IPv4 subnet mask from the IPv4 address prefix, not from
  the last route with prefix length > 0.

Bug: 62171690
Test: make -j64 RunSettingsRoboTests
Test: IP information does not flicker when signal strength changes
Change-Id: Ia9f2a277e53a2800407ae327701c5b95a9eec20a
2017-06-01 12:08:41 +09:00

54 lines
1.7 KiB
Java

/*
* Copyright (C) 2009 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.wifi;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
import com.android.settings.R;
/**
* A Preference to be used with the Wifi Network Detail Fragment that allows a summary text to be
* set inside the widget resource
*/
public class WifiDetailPreference extends Preference {
private String mDetailText;
public WifiDetailPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setWidgetLayoutResource(R.layout.preference_widget_summary);
}
public void setDetailText(String text) {
if (TextUtils.equals(mDetailText, text)) return;
mDetailText = text;
notifyChanged();
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
TextView textView = ((TextView) view.findViewById(R.id.widget_summary));
textView.setText(mDetailText);
textView.setPadding(0, 0, 10, 0);
}
}