瀏覽代碼

Hide read status setting if old talk version used

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 年之前
父節點
當前提交
e563230fb2

+ 3 - 3
app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.kt

@@ -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)
             }
         }

+ 5 - 1
app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java

@@ -457,7 +457,11 @@ public class SettingsController extends BaseController {
             ((Checkable) incognitoKeyboardSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getIsKeyboardIncognito());
         }
 
-        ((Checkable) readPrivacyPreference.findViewById(R.id.mp_checkable)).setChecked(!currentUser.isReadStatusPrivate());
+        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());

+ 19 - 0
app/src/main/java/com/nextcloud/talk/models/database/User.java

@@ -146,6 +146,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) {