diff --git a/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java b/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java index a26ea4e6..5eed1a8f 100644 --- a/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java +++ b/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java @@ -8,12 +8,12 @@ import org.jsoup.Connection; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; -import org.jsoup.helper.HttpConnection.Response; import java.io.IOException; -import java.io.OutputStreamWriter; import java.util.Map; +import leszcz_team.wulkanowy.R; + public class Login extends AsyncTask { String email; @@ -25,17 +25,30 @@ public class Login extends AsyncTask { Activity activity; String userMesage; - String urlForStepOne = "https://cufs.vulcan.net.pl/Default/Account/LogOn"; - String urlForStepTwo = "https://cufs.vulcan.net.pl/{locationID}/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx"; - String urlForStepThree = "https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx"; + String urlForStepOne; + String urlForStepTwo; + String urlForStepThree; public Login(String emailT, String passwordT, String countyT, Activity mainAC){ - email = emailT; - password = passwordT; - - county = "powiat" + countyT.substring(7); activity = mainAC; + + if (emailT.equals("Debug")){ + urlForStepOne = activity.getString(R.string.urlStepOneDebug); + urlForStepTwo = activity.getString(R.string.urlStepTwoDebug); + urlForStepThree = activity.getString(R.string.urlStepThreeDebug); + county = activity.getString(R.string.countyDebug); + email = activity.getString(R.string.emailDebug); + password = passwordT; + } + else{ + urlForStepOne = activity.getString(R.string.urlStepOneRelease); + urlForStepTwo = activity.getString(R.string.urlStepTwoRelease); + urlForStepThree = activity.getString(R.string.urlStepThreeRelease); + county = "powiat" + countyT.substring(7); + email = emailT; + password = passwordT; + } } @Override @@ -54,9 +67,10 @@ public class Login extends AsyncTask { String helloText = dashboardHtml.getElementsByClass("welcome").text(); if (helloText.equals("Dzień dobry!")) { - userMesage = "Zalogowano pomyślnie! " + helloText; - } else { - userMesage = "Coś poszło nie tak :/"; + userMesage = activity.getString(R.string.login_accepted); + } + else { + userMesage = activity.getString(R.string.login_denied); } } catch (IOException e){ diff --git a/app/src/main/java/leszcz_team/wulkanowy/activity/main/MainActivity.java b/app/src/main/java/leszcz_team/wulkanowy/activity/main/MainActivity.java index 0b992e78..79f65cb4 100644 --- a/app/src/main/java/leszcz_team/wulkanowy/activity/main/MainActivity.java +++ b/app/src/main/java/leszcz_team/wulkanowy/activity/main/MainActivity.java @@ -54,12 +54,13 @@ public class MainActivity extends Activity { String email = adressEmail.getText().toString(); String county = countyText.getText().toString(); - if (password.isEmpty() || email.isEmpty() || county.isEmpty()){ - Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show(); - } - else{ + if (!email.isEmpty() || !password.isEmpty() || !county.isEmpty()){ new Login(email, password, county, this).execute(); } + else if (password.isEmpty() || email.isEmpty() || county.isEmpty()) { + Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show(); + + } } } diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index b556b493..0ce47cd2 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -11,4 +11,6 @@ Ostrzeżenie Brak danych logowania Funkcja którą chciałeś uruchomić nie działa + Pomyślnie zalogowano + Logowanie nie powiodło się \ No newline at end of file diff --git a/app/src/main/res/values/loginData.xml b/app/src/main/res/values/loginData.xml new file mode 100644 index 00000000..41b0b776 --- /dev/null +++ b/app/src/main/res/values/loginData.xml @@ -0,0 +1,12 @@ + + + https://cufs.vulcan.net.pl/Default/Account/LogOn + https://cufs.vulcan.net.pl/{locationID}/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx + https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx" + https://cufsdemo.vulcan.net.pl/Default/Account/LogOn + https://cufsdemo.vulcan.net.pl/{locationID}/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplusdemo.vulcan.net.pl/{locationID}/LoginEndpoint.aspx&wctx=https://uonetplusdemo.vulcan.net.pl/{locationID}/LoginEndpoint.aspx + https://uonetplusdemo.vulcan.net.pl/{locationID}/LoginEndpoint.aspx" + u43063@demouonetplus.vulcan.net.pl + demouonetplus + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8765bcea..9859e9ff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -10,4 +10,6 @@ Warning No login data The function you wanted to run does not work + Login is successful + Login is failed