浏览代码

Add a warning when the server version is (almost) EOL

Signed-off-by: Joas Schilling <coding@schilljs.com>
Joas Schilling 4 年之前
父节点
当前提交
01b760f97e

+ 14 - 0
app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java

@@ -144,6 +144,8 @@ public class SettingsController extends BaseController {
     EmojiTextView displayNameTextView;
     @BindView(R.id.base_url_text)
     TextView baseUrlTextView;
+    @BindView(R.id.server_age_warning_text)
+    TextView serverAgeTextView;
     @BindView(R.id.settings_call_sound)
     MaterialStandardPreference settingsCallSound;
     @BindView(R.id.settings_message_sound)
@@ -551,6 +553,18 @@ public class SettingsController extends BaseController {
 
             baseUrlTextView.setText(Uri.parse(currentUser.getBaseUrl()).getHost());
 
+            if (!currentUser.hasSpreedFeatureCapability("no-ping")) {
+                // Talk 4+
+                serverAgeTextView.setTextColor(getResources().getColor(R.color.nc_darkRed));
+                serverAgeTextView.setText(R.string.nc_settings_server_eol);
+            } else if (!currentUser.hasSpreedFeatureCapability("chat-replies")) {
+                // Talk 8+
+                serverAgeTextView.setTextColor(getResources().getColor(R.color.nc_darkYellow));
+                serverAgeTextView.setText(R.string.nc_settings_server_almost_eol);
+            } else {
+                serverAgeTextView.setVisibility(View.GONE);
+            }
+
             reauthorizeButton.addPreferenceClickListener(view14 -> {
                 getRouter().pushController(RouterTransaction.with(
                         new WebViewLoginController(currentUser.getBaseUrl(), true))

+ 12 - 2
app/src/main/res/layout/controller_settings.xml

@@ -71,7 +71,17 @@
                 android:layout_centerHorizontal="true"
                 android:layout_margin="4dp"
                 android:textColor="@color/medium_emphasis_text"
-                tools:text="jane@nextcloud.com" />
+                tools:text="nextcloud.com" />
+
+            <TextView
+                android:id="@+id/server_age_warning_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/base_url_text"
+                android:layout_centerHorizontal="true"
+                android:layout_margin="@dimen/standard_margin"
+                android:textColor="@color/nc_darkRed"
+                tools:text="@string/nc_settings_server_almost_eol" />
 
             <com.facebook.drawee.view.SimpleDraweeView
                 android:id="@+id/avatar_image"
@@ -87,7 +97,7 @@
                 android:id="@+id/settings_switch"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_below="@id/base_url_text"
+                android:layout_below="@id/server_age_warning_text"
                 android:tag="switchAccountButton"
                 apc:mp_title="@string/nc_settings_switch_account" />
 

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -50,6 +50,7 @@
     <color name="conversation_unread_bubble_text">#222222</color>
 
     <color name="nc_darkRed">#D32F2F</color>
+    <color name="nc_darkYellow">#FF9800</color>
     <color name="nc_darkGreen">#006400</color>
     <color name="controller_chat_separator">#E8E8E8</color>
     <color name="grey_600">#757575</color>

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -85,6 +85,10 @@
     <string name="nc_settings_remove_confirmation">Please confirm your intent to remove the current account.</string>
     <string name="nc_settings_remove_account">Remove account</string>
     <string name="nc_settings_add_account">Add a new account</string>
+    <string name="nc_settings_server_eol">The server version is too old and not supported by this version of the
+        Android app</string>
+    <string name="nc_settings_server_almost_eol">The server version is very old and will not be supported in the next
+        release!</string>
     <string name="nc_add">Add</string>
     <string name="nc_settings_wrong_account">Only current account can be reauthorized</string>
     <string name="nc_settings_no_talk_installed">Talk app is not installed on the server you tried to authenticate against</string>