One updateSummary method called by all VPN prefs

Having multiple methods means inevitably when new features are added to
the preferences, the right calls aren't made so information on the
screen lags between updates.

Bug: 28257641
Change-Id: I336aeefd5941ccf808dc9070427209a7d2530032
(cherry picked from commit 903843e6f9)
This commit is contained in:
Robin Lee
2016-04-19 12:29:02 +01:00
parent 0e048a11c7
commit e06d757a0c
3 changed files with 20 additions and 33 deletions

View File

@@ -32,9 +32,8 @@ import com.android.internal.net.VpnConfig;
*/
public class AppPreference extends ManageablePreference {
public static final int STATE_CONNECTED = LegacyVpnInfo.STATE_CONNECTED;
public static final int STATE_DISCONNECTED = LegacyVpnInfo.STATE_DISCONNECTED;
public static final int STATE_DISCONNECTED = STATE_NONE;
private int mState = STATE_DISCONNECTED;
private String mPackageName;
private String mName;
@@ -70,22 +69,11 @@ public class AppPreference extends ManageablePreference {
update();
}
public int getState() {
return mState;
}
public void setState(int state) {
mState = state;
update();
}
private void update() {
if (mPackageName == null || mUserId == UserHandle.USER_NULL) {
return;
}
setSummary(getSummaryString(mState == STATE_DISCONNECTED ? STATE_NONE : mState));
mName = mPackageName;
Drawable icon = null;
@@ -113,6 +101,7 @@ public class AppPreference extends ManageablePreference {
}
setTitle(mName);
setIcon(icon);
updateSummary();
notifyHierarchyChanged();
}