Fixes an issue with instance names and special characters

This commit is contained in:
tom79 2017-07-29 13:09:09 +02:00
parent d7387d903f
commit 07ec513e1a
4 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import android.graphics.Paint;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Patterns;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -103,7 +104,12 @@ public class LoginActivity extends AppCompatActivity {
connectionButton.setEnabled(false);
login_two_step.setVisibility(View.INVISIBLE);
if (!hasFocus) {
retrievesClientId();
if( Patterns.WEB_URL.matcher(login_instance.getText().toString().trim()).matches() ){
retrievesClientId();
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_instance, Toast.LENGTH_LONG).show();
}
}
}
});

View File

@ -45,7 +45,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textWebEmailAddress"
android:hint="@string/instance"
android:hint="@string/instance_example"
/>
<EditText
android:id="@+id/login_uid"

View File

@ -33,6 +33,7 @@
<string name="other_instance">Autre instance que mastodon.etalab.gouv.fr ?</string>
<string name="no_result">Aucun résultat !</string>
<string name="instance">Instance</string>
<string name="instance_example">Instance : mastodon.social</string>
<string name="toast_account_changed">Utilisation du compte %1$s</string>
<string name="add_account">Ajouter un compte</string>
<string name="clipboard">Le contenu du pouet a été copié dans le presse-papier</string>
@ -228,6 +229,7 @@
<string name="toast_unstatus">Le pouet a été supprimé !</string>
<string name="toast_error">Oups ! Une erreur s\'est produite !</string>
<string name="toast_code_error">Une erreur s\'est produite ! L\'instance n\'a retourné aucun code d\authorisation !</string>
<string name="toast_error_instance">Le nom de l\'instance ne semble pas être valide !</string>
<string name="toast_error_loading_account">Une erreur s\'est produite en chargeant le compte !</string>
<string name="toast_error_search">Une erreur s\'est produite lors de la recherche !</string>
<string name="toast_error_login">Impossible de vous connecter !</string>

View File

@ -34,6 +34,7 @@
<string name="other_instance">Other instance than mastodon.etalab.gouv.fr?</string>
<string name="no_result">No results!</string>
<string name="instance">Instance</string>
<string name="instance_example">Instance: mastodon.social</string>
<string name="toast_account_changed">Now works with the account %1$s</string>
<string name="add_account">Add an account</string>
<string name="clipboard">The content of the toot has been copied to the clipboard</string>
@ -233,6 +234,7 @@
<string name="toast_unstatus">The toot was deleted!</string>
<string name="toast_error">Oops ! An error occurred!</string>
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
<string name="toast_error_instance">The instance domain does not seem to be valide!</string>
<string name="toast_error_loading_account">An error occurred while switching between accounts!</string>
<string name="toast_error_search">An error occurred while searching!</string>
<string name="toast_error_login">Can not log in!</string>