Просмотр исходного кода

Add providers

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 лет назад
Родитель
Сommit
b47a736763

+ 22 - 0
app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java

@@ -20,7 +20,9 @@
 
 package com.nextcloud.talk.controllers;
 
+import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.net.Uri;
 import android.support.annotation.NonNull;
 import android.text.Editable;
 import android.text.TextUtils;
@@ -30,6 +32,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
 import android.widget.ProgressBar;
+import android.widget.TextView;
 
 import com.bluelinelabs.conductor.RouterTransaction;
 import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
@@ -63,6 +66,8 @@ public class ServerSelectionController extends BaseController {
     TextFieldBoxes textFieldBoxes;
     @BindView(R.id.progress_bar)
     ProgressBar progressBar;
+    @BindView(R.id.providers_text_view)
+    TextView providersTextView;
 
     @Inject
     NcApi ncApi;
@@ -94,6 +99,16 @@ public class ServerSelectionController extends BaseController {
         textFieldBoxes.getEndIconImageButton().setVisibility(View.VISIBLE);
         textFieldBoxes.getEndIconImageButton().setOnClickListener(view1 -> checkServerAndProceed());
 
+        if (TextUtils.isEmpty(getResources().getString(R.string.nc_providers_url))) {
+            providersTextView.setVisibility(View.GONE);
+        } else {
+            providersTextView.setOnClickListener(view12 -> {
+                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources()
+                        .getString(R.string.nc_providers_url)));
+                startActivity(browserIntent);
+            });
+        }
+
         serverEntry.requestFocus();
 
         serverEntry.addTextChangedListener(new TextWatcher() {
@@ -142,6 +157,7 @@ public class ServerSelectionController extends BaseController {
 
         serverEntry.setEnabled(false);
         progressBar.setVisibility(View.VISIBLE);
+        providersTextView.setVisibility(View.INVISIBLE);
 
         if (url.endsWith("/")) {
             url = url.substring(0, url.length() - 1);
@@ -176,20 +192,24 @@ public class ServerSelectionController extends BaseController {
                         textFieldBoxes.setError(String.format(
                                 getResources().getString(R.string.nc_server_not_installed), productName),
                                 true);
+                        toggleProceedButton(false);
                     } else if (status.isNeedsUpgrade()) {
                         textFieldBoxes.setError(String.format(getResources().
                                         getString(R.string.nc_server_db_upgrade_needed),
                                 productName), true);
+                        toggleProceedButton(false);
                     } else if (status.isMaintenance()) {
                         textFieldBoxes.setError(String.format(getResources().
                                         getString(R.string.nc_server_maintenance),
                                 productName),
                                 true);
+                        toggleProceedButton(false);
                     } else if (!status.getVersion().startsWith("13.")) {
                         textFieldBoxes.setError(String.format(getResources().
                                         getString(R.string.nc_server_version),
                                 getResources().getString(R.string.nc_app_name)
                                 , productName), true);
+                        toggleProceedButton(false);
                     }
 
                 }, throwable -> {
@@ -208,12 +228,14 @@ public class ServerSelectionController extends BaseController {
                         }
 
                         progressBar.setVisibility(View.GONE);
+                        providersTextView.setVisibility(View.VISIBLE);
                         toggleProceedButton(false);
 
                         dispose();
                     }
                 }, () -> {
                     progressBar.setVisibility(View.GONE);
+                    providersTextView.setVisibility(View.VISIBLE);
                     dispose();
                 });
     }

+ 15 - 2
app/src/main/res/layout/controller_server_selection.xml

@@ -45,9 +45,9 @@
         android:layout_marginLeft="@dimen/activity_horizontal_margin"
         android:layout_marginRight="@dimen/activity_horizontal_margin"
         android:layout_marginStart="@dimen/activity_horizontal_margin"
-        app:labelText="@string/nc_server_url"
         app:errorColor="@color/nc_white_color_complete"
         app:helperText=" "
+        app:labelText="@string/nc_server_url"
         app:panelBackgroundColor="@color/colorPrimary"
         app:primaryColor="@color/nc_white_color_complete">
 
@@ -75,8 +75,21 @@
         android:layout_marginStart="@dimen/activity_horizontal_margin"
         android:layout_marginTop="24dp"
         android:indeterminate="true"
-        android:indeterminateTintMode="src_in"
         android:indeterminateTint="@color/nc_white_color_complete"
+        android:indeterminateTintMode="src_in"
         android:visibility="invisible"/>
 
+    <TextView
+        android:id="@+id/providers_text_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/progress_bar"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="56dp"
+        android:lines="2"
+        android:text="@string/nc_get_from_provider"
+        android:textAlignment="center"
+        android:textAllCaps="true"
+        android:textColor="@color/nc_white_color_complete"/>
+
 </RelativeLayout>

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

@@ -13,4 +13,5 @@
     <string name="nc_privacy_url">https://nextcloud.com/privacy/</string>
     <string name="nc_gpl3_url">https://www.gnu.org/licenses/gpl-3.0.en.html</string>
     <string name="nc_source_code_url">https://github.com/nextcloud/talk-android</string>
+    <string name="nc_providers_url">https://nextcloud.com/providers</string>
 </resources>

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

@@ -11,6 +11,7 @@
     <string name="nc_server_db_upgrade_needed">Please upgrade your %1$s database</string>
     <string name="nc_server_maintenance">Please bring your %1$s out of maintenance</string>
     <string name="nc_server_version">%1$s only works with %2$s 13 and up</string>
+    <string name="nc_get_from_provider">Do you not have a server yet?\nClick here to get one from a provider</string>
 
     <!-- Account verification -->
     <string name="nc_display_name_fetched">Display name fetched</string>