Correctly disable preferences in group conversation preferences

Fixes #7031
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-10-03 17:05:52 -07:00
parent b7340cc356
commit 5de89d4f26
2 changed files with 10 additions and 4 deletions

View File

@ -38,7 +38,7 @@
app:numColumns="5" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:key="divider" android:layout="@layout/preference_divider"/>
<PreferenceCategory android:key="privacy_settings" android:title="@string/recipient_preferences__privacy">

View File

@ -24,6 +24,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
@ -270,6 +271,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
Log.w(TAG, "onCreatePreferences...");
addPreferencesFromResource(R.xml.recipient_preferences);
}
@ -316,6 +318,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
ColorPickerPreference colorPreference = (ColorPickerPreference) this.findPreference(PREFERENCE_COLOR);
Preference blockPreference = this.findPreference(PREFERENCE_BLOCK);
Preference identityPreference = this.findPreference(PREFERENCE_IDENTITY);
PreferenceCategory privacyCategory = (PreferenceCategory)this.findPreference("privacy_settings");
PreferenceCategory divider = (PreferenceCategory)this.findPreference("divider");
mutePreference.setChecked(recipient.isMuted());
@ -348,9 +352,11 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
}
if (recipient.isGroupRecipient()) {
if (colorPreference != null) getPreferenceScreen().removePreference(colorPreference);
if (blockPreference != null) getPreferenceScreen().removePreference(blockPreference);
if (identityPreference != null) getPreferenceScreen().removePreference(identityPreference);
if (colorPreference != null) colorPreference.setVisible(false);
if (blockPreference != null) blockPreference.setVisible(false);
if (identityPreference != null) identityPreference.setVisible(false);
if (privacyCategory != null) privacyCategory.setVisible(false);
if (divider != null) divider.setVisible(false);
} else {
colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity()));
colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity()));