Commit d4b0e5c4 authored by Bastien Le Querrec's avatar Bastien Le Querrec

[WIP] fix summary update

parent b1d81e85
......@@ -8,7 +8,8 @@
android:title="@string/preferences__enable_web_interface"
android:summary="@string/preferences__enable_this_option_to_send_and_receive_messages_from_your_desktop" />
<EditTextPreference android:key="preference_web_interface_passphrase"
<EditTextPreference android:id="@+id/preference_web_interface_passphrase"
android:key="pref_web_interface_passphrase"
android:title="@string/preferences_web_interface_passphrase"
android:inputType="text"
android:dependency="pref_enable_web_interface" />
......
......@@ -22,7 +22,8 @@ public class WebPreferenceFragment extends PreferenceFragment {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.preferences_web);
updatePassphraseDisplay();
findPreference(SMSSecurePreferences.WEB_INTERFACE_PASSPHRASE)
.setSummary(SMSSecurePreferences.getWebInterfacePassphrase(getActivity()));
findPreference(SMSSecurePreferences.WEB_INTERFACE_ENABLED)
.setOnPreferenceClickListener(new InitializePassphrase());
......@@ -55,14 +56,15 @@ public class WebPreferenceFragment extends PreferenceFragment {
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
byte[] salt = new byte[16];
random.nextBytes(salt);
SMSSecurePreferences.setWebInterfacePassphrase(context, Base64.encodeBytes(salt));
String passphrase = Base64.encodeBytes(salt);
SMSSecurePreferences.setWebInterfacePassphrase(context, passphrase);
findPreference(SMSSecurePreferences.WEB_INTERFACE_PASSPHRASE).setSummary(passphrase);
} catch (Exception e) {
Log.w(TAG, e);
throw new AssertionError(e);
}
updatePassphraseDisplay();
return true;
}
}
......@@ -74,15 +76,10 @@ public class WebPreferenceFragment extends PreferenceFragment {
if (newValue.toString().equals("")) {
return false;
} else {
updatePassphraseDisplay();
preference.setSummary(newValue.toString());
return true;
}
}
}
private void updatePassphraseDisplay() {
findPreference(SMSSecurePreferences.WEB_INTERFACE_PASSPHRASE)
.setSummary(SMSSecurePreferences.getWebInterfacePassphrase(getActivity()));
}
}
......@@ -93,7 +93,7 @@ public class SMSSecurePreferences {
private static final String MEDIA_DOWNLOAD_ROAMING_PREF = "pref_media_download_roaming";
public static final String WEB_INTERFACE_ENABLED = "pref_enable_web_interface";
public static final String WEB_INTERFACE_PASSPHRASE = "preference_web_interface_passphrase";
public static final String WEB_INTERFACE_PASSPHRASE = "pref_web_interface_passphrase";
public static NotificationPrivacyPreference getNotificationPrivacy(Context context) {
return new NotificationPrivacyPreference(getStringPreference(context, NOTIFICATION_PRIVACY_PREF, "all"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment