This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

Commit d117f3d2 by Nico Suhl

check for valid url

parent f8912b31
......@@ -49,7 +49,6 @@ public class KassenUpdateDatasets extends AsyncTask<RequestType, Void, Void> {
switch(params[0]) {
case PRODUCTS:
result = KassenHttpUtils.getPage(ctx, KassenConfig.KASSEN_SUBDIR_BUYABLE);
Log.e("nighoo", result);
mItems = new JSONArray(result);
ctx.getContentResolver().delete(KassenContentProvider.CONTENT_PRODUCTS, null, null);
......
......@@ -6,6 +6,7 @@ import android.app.ProgressDialog;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Patterns;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
......@@ -25,7 +26,7 @@ import de.k4ever.k4android.utils.KassenHttpUtils.HttpTaskResultReceiver;
import de.k4ever.k4android.utils.KassenUtils;
public class LoginFragment extends DialogFragment implements OnEditorActionListener {
private EditText mAPIUrl, mPassword, mUsername;
private EditText mServerURL, mPassword, mUsername;
@Override
public void onCreate(Bundle savedInstanceState) {
......@@ -41,9 +42,9 @@ public class LoginFragment extends DialogFragment implements OnEditorActionListe
mUsername = (EditText) v.findViewById(R.id.username);
mUsername.setText(PreferenceManager.getDefaultSharedPreferences(
getActivity()).getString("pref_username", ""));
mAPIUrl = (EditText) v.findViewById(R.id.apiurl);
mAPIUrl.setText(PreferenceManager.getDefaultSharedPreferences(
getActivity()).getString("pref_apiurl", ""));
mServerURL = (EditText) v.findViewById(R.id.apiurl);
mServerURL.setText(PreferenceManager.getDefaultSharedPreferences(
getActivity()).getString("pref_apiurl", ""));
mPassword = (EditText) v.findViewById(R.id.password);
mPassword.setOnEditorActionListener(this);
mPassword.setText(PreferenceManager.getDefaultSharedPreferences(
......@@ -71,26 +72,32 @@ public class LoginFragment extends DialogFragment implements OnEditorActionListe
}
private void login() {
if( mAPIUrl.getText().toString().length() == 0 ) {
mAPIUrl.setError(getText(R.string.error_no_input));
mAPIUrl.requestFocus();
if (mServerURL.getText().toString().length() == 0 ) {
mServerURL.setError(getText(R.string.error_no_input));
mServerURL.requestFocus();
return;
}
if( mUsername.getText().toString().length() == 0 ) {
if (!Patterns.WEB_URL.matcher(mServerURL.getText()).matches()) {
mServerURL.setError(getText(R.string.error_no_weburl));
mServerURL.requestFocus();
return;
}
if (mUsername.getText().toString().length() == 0 ) {
mUsername.setError(getText(R.string.error_no_input));
mUsername.requestFocus();
return;
}
if( mPassword.getText().toString().length() == 0 ) {
if (mPassword.getText().toString().length() == 0 ) {
mPassword.setError(getText(R.string.error_no_input));
mPassword.requestFocus();
return;
}
// make sure URL ends with slash
String k4everUrl = mAPIUrl.getText().toString();
String k4everUrl = mServerURL.getText().toString();
if (!k4everUrl.endsWith("/"))
k4everUrl += "/";
final String k4everApiUrl = k4everUrl + KassenConfig.KASSEN_SUBDIR_API;
......@@ -104,7 +111,7 @@ public class LoginFragment extends DialogFragment implements OnEditorActionListe
prefs.apply();
KassenHttpUtils.recreateInstance();
new HttpRequestTask(new HttpTaskResultReceiver() {
ProgressDialog dialog;
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment