From b47a736763688276bdcfb2d1a807902e20b5412a Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 18 Dec 2017 23:21:27 +0100 Subject: [PATCH] Add providers Signed-off-by: Mario Danic --- .../ServerSelectionController.java | 22 +++++++++++++++++++ .../layout/controller_server_selection.xml | 17 ++++++++++++-- app/src/main/res/values/setup.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java b/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java index 7f3142c62..16d7ce19f 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.java +++ b/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(); }); } diff --git a/app/src/main/res/layout/controller_server_selection.xml b/app/src/main/res/layout/controller_server_selection.xml index 1a4724a42..8f7cfc9da 100644 --- a/app/src/main/res/layout/controller_server_selection.xml +++ b/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"/> + + diff --git a/app/src/main/res/values/setup.xml b/app/src/main/res/values/setup.xml index 39715c913..fcb258524 100644 --- a/app/src/main/res/values/setup.xml +++ b/app/src/main/res/values/setup.xml @@ -13,4 +13,5 @@ https://nextcloud.com/privacy/ https://www.gnu.org/licenses/gpl-3.0.en.html https://github.com/nextcloud/talk-android + https://nextcloud.com/providers diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 811188776..60fe9c29f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,6 +11,7 @@ Please upgrade your %1$s database Please bring your %1$s out of maintenance %1$s only works with %2$s 13 and up + Do you not have a server yet?\nClick here to get one from a provider Display name fetched