Fix secret EditText display and other fixes.
+ Now it shows shadowed "(unchanged)" (as in wifi settings) and "(not set)" instead of two dots. Patch Set 2: + Show cancellation confirmation dialog only when there's change in profile. Patch Set 3: + Re-enable profile preferences when the reconnect dialog is cancelled.
This commit is contained in:
@@ -27,6 +27,7 @@ import android.net.vpn.L2tpProfile;
|
||||
import android.net.vpn.VpnProfile;
|
||||
import android.net.vpn.VpnType;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceGroup;
|
||||
@@ -47,6 +48,7 @@ public class VpnEditor extends PreferenceActivity {
|
||||
|
||||
private VpnProfileEditor mProfileEditor;
|
||||
private boolean mAddingProfile;
|
||||
private byte[] mOriginalProfileData;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -61,6 +63,10 @@ public class VpnEditor extends PreferenceActivity {
|
||||
addPreferencesFromResource(R.xml.vpn_edit);
|
||||
|
||||
initViewFor(p);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
p.writeToParcel(parcel, 0);
|
||||
mOriginalProfileData = parcel.marshall();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +96,11 @@ public class VpnEditor extends PreferenceActivity {
|
||||
return true;
|
||||
|
||||
case MENU_CANCEL:
|
||||
showCancellationConfirmDialog();
|
||||
if (profileChanged()) {
|
||||
showCancellationConfirmDialog();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@@ -131,7 +141,7 @@ public class VpnEditor extends PreferenceActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
setResult(getProfile());
|
||||
if (profileChanged()) setResult(getProfile());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -177,4 +187,17 @@ public class VpnEditor extends PreferenceActivity {
|
||||
private VpnProfile getProfile() {
|
||||
return mProfileEditor.getProfile();
|
||||
}
|
||||
|
||||
private boolean profileChanged() {
|
||||
Parcel newParcel = Parcel.obtain();
|
||||
getProfile().writeToParcel(newParcel, 0);
|
||||
byte[] newData = newParcel.marshall();
|
||||
if (mOriginalProfileData.length == newData.length) {
|
||||
for (int i = 0, n = mOriginalProfileData.length; i < n; i++) {
|
||||
if (mOriginalProfileData[i] != newData[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user