Hide read status setting if old talk version used

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-12-18 15:04:08 +01:00
parent 98e2117bdf
commit e563230fb2
No known key found for this signature in database
GPG Key ID: 0E00D4D47D0C5AF7
3 changed files with 27 additions and 4 deletions

View File

@ -192,9 +192,9 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
else -> null
}
readStatusDrawableInt?.let {
context?.resources?.getDrawable(it, null)?.let {
it.setColorFilter(context?.resources!!.getColor(R.color.warm_grey_four), PorterDuff.Mode.SRC_ATOP)
readStatusDrawableInt?.let { drawableInt ->
context?.resources?.getDrawable(drawableInt, null)?.let {
it.setColorFilter(context?.resources!!.getColor(R.color.white60), PorterDuff.Mode.SRC_ATOP)
checkMark?.setImageDrawable(it)
}
}

View File

@ -457,7 +457,11 @@ public class SettingsController extends BaseController {
((Checkable) incognitoKeyboardSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getIsKeyboardIncognito());
}
if (userUtils.getCurrentUser().isReadStatusAvailable()) {
((Checkable) readPrivacyPreference.findViewById(R.id.mp_checkable)).setChecked(!currentUser.isReadStatusPrivate());
} else {
readPrivacyPreference.setVisibility(View.GONE);
}
((Checkable) linkPreviewsSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getAreLinkPreviewsAllowed());
((Checkable) phoneBookIntegretationPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.isPhoneBookIntegrationEnabled());

View File

@ -147,6 +147,25 @@ public interface User extends Parcelable, Persistable, Serializable {
return false;
}
default boolean isReadStatusAvailable() {
if (getCapabilities() != null) {
Capabilities capabilities;
try {
capabilities = LoganSquare.parse(getCapabilities(), Capabilities.class);
if (capabilities != null &&
capabilities.getSpreedCapability() != null &&
capabilities.getSpreedCapability().getConfig() != null &&
capabilities.getSpreedCapability().getConfig().containsKey("chat")) {
HashMap<String, String> map = capabilities.getSpreedCapability().getConfig().get("chat");
return map != null && map.containsKey("read-privacy");
}
} catch (IOException e) {
e.printStackTrace();
}
}
return false;
}
default boolean isReadStatusPrivate() {
if (getCapabilities() != null) {
Capabilities capabilities;