diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6f13a57..bcc4c2a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java b/app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java similarity index 95% rename from app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java rename to app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java index d27ebc0..1167678 100644 --- a/app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java +++ b/app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java @@ -35,7 +35,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public class WebActivity extends AppCompatActivity +public class CabinetActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @@ -272,7 +272,7 @@ public class WebActivity extends AppCompatActivity // НЕИЗВЕСТНОЕ ИСКЛЮЧЕНИЕ public void unknownState(int currentState){ Log.e("unknownState","Не удалось получить ссылки на странице студента"); - Log.e("unknownState",browser.getUrl()); + Log.e("unknownState",getURL()); finish(); } // АВТОРИЗАЦИЯ @@ -283,8 +283,8 @@ public class WebActivity extends AppCompatActivity Log.i("Auth|Login", login); Log.i("Auth|Password", password); //console("Auth|Password",MainActivity.password.getText().toString()); - //browser.loadUrl("javascript:apex.submit({request:'LOGIN',set:{'P101_USERNAME':'s75389','P101_PASSWORD':'v97KFxmP'}});"); - browser.loadUrl("javascript:apex.submit({request:'LOGIN',set:{'P101_USERNAME':'"+login+"','P101_PASSWORD':'"+password+"'}});"); + //loadSite("javascript:apex.submit({request:'LOGIN',set:{'P101_USERNAME':'s75389','P101_PASSWORD':'v97KFxmP'}});"); + loadSite("javascript:apex.submit({request:'LOGIN',set:{'P101_USERNAME':'"+login+"','P101_PASSWORD':'"+password+"'}});"); return true; } @@ -293,7 +293,7 @@ public class WebActivity extends AppCompatActivity if(taskFinished) return 127; Intent intent = new Intent(); Log.i("sessionActive","Checking session"); - String a = parser.cutLine("http://web-iais.admin.tstu.ru:7777/zion/f?p=503:",":",browser.getUrl()); + String a = parser.cutLine("http://web-iais.admin.tstu.ru:7777/zion/f?p=503:",":",getURL()); switch (a){ case "LOGIN_DESKTOP": Log.i("sessionActive","Окно авторизации"); @@ -308,7 +308,7 @@ public class WebActivity extends AppCompatActivity case "1": Log.i("sessionActive","Страница студента"); intent.putExtra("error","Вход производился успешно"); - MainURL = browser.getUrl(); + MainURL = getURL(); taskGenerator(2); return 2; case "40": @@ -322,11 +322,11 @@ public class WebActivity extends AppCompatActivity case "43": Log.i("sessionActive","Страница - Рейтинг|Главная"); String s = parser.cutLine("","503:",MainURL) + "503:43:" + parser.cutLine(":1:","",MainURL)+":"; - if(parser.cutLine(s,":NO:",browser.getUrl()).equals("RATE_GROUP")) { + if(parser.cutLine(s,":NO:", getURL()).equals("RATE_GROUP")) { taskGenerator(6); return 6; } - if(parser.cutLine(s,":NO:",browser.getUrl()).equals("RATE_INST")) { + if(parser.cutLine(s,":NO:", getURL()).equals("RATE_INST")) { taskGenerator(7); return 7; } @@ -350,7 +350,7 @@ public class WebActivity extends AppCompatActivity MainHTML); studentName.setText(parser.cutLine(""," /",studNameGroup)); studentGroup.setText("Группа: " + parser.cutLine("/ ","",studNameGroup)); - browser.loadUrl("javascript:apex.submit('T_ЗАНЯТИЯ/ОЦЕНКИ');"); + loadSite("javascript:apex.submit('T_ЗАНЯТИЯ/ОЦЕНКИ');"); break; case 3: AdditionalHTML = siteBuf; @@ -358,11 +358,11 @@ public class WebActivity extends AppCompatActivity parser.cutLine("",AdditionalHTML); RateValueURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine("",AdditionalHTML); - browser.loadUrl(JournalURL); + loadSite(JournalURL); break; case 4: JournalHTML = siteBuf; - browser.loadUrl(RateValueURL); + loadSite(RateValueURL); break; case 5: RateValueHTML = siteBuf; @@ -370,12 +370,12 @@ public class WebActivity extends AppCompatActivity studentRate.setText("Балл: " + rate); GroupRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine(">",RateValueHTML); FacultyRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine("", RateValueHTML); - browser.loadUrl(GroupRateURL); + loadSite(GroupRateURL); break; case 6: GroupRateHTML = siteBuf; fillGroup(); - browser.loadUrl(FacultyRateURL); + loadSite(FacultyRateURL); break; case 7: FacultyRateHTML = siteBuf; @@ -472,7 +472,6 @@ public class WebActivity extends AppCompatActivity @TargetApi(19) public void getHTML(){ - browser.evaluateJavascript("javascript:document.documentElement.outerHTML;", new ValueCallback() { @Override public void onReceiveValue(String s) { @@ -484,6 +483,10 @@ public class WebActivity extends AppCompatActivity }); } + public String getURL(){ + return browser.getUrl(); + } + public void encodeHTML(){ if(siteBuf != null){ OldParser parser = new OldParser(); @@ -498,7 +501,7 @@ public class WebActivity extends AppCompatActivity @Override public void onPageFinished(WebView view, String url) { getHTML(); - Log.i("onPageFinished", browser.getUrl()); + Log.i("onPageFinished", getURL()); } } } diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java b/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java index 33125b4..f78efe9 100644 --- a/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java +++ b/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java @@ -1,8 +1,5 @@ package ru.defend.defdevteam.tstu; -import android.app.Activity; -import android.widget.TextView; - /** * Created by thedefend on 29.11.16. */ @@ -13,13 +10,13 @@ public class FeedController { FeedUpdater feedUpdater; String newsFeed; int updateRate; //in minutes - private WebActivity activity; + private CabinetActivity activity; - public FeedController(WebActivity activity, int updateRate) { + public FeedController(CabinetActivity activity, int updateRate) { this(activity, updateRate, "http://press.tstu.ru/?format=feed"); } - public FeedController(WebActivity activity, int updateRate, String rssUrl) { + public FeedController(CabinetActivity activity, int updateRate, String rssUrl) { feedReader = new FeedReader(this, rssUrl); feedUpdater = new FeedUpdater(); this.activity = activity; diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java b/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java index bb28ed5..7bbefdc 100644 --- a/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java +++ b/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java @@ -1,24 +1,14 @@ package ru.defend.defdevteam.tstu; -import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; -import android.widget.ListView; -import android.widget.TextView; - -import java.util.ArrayList; -import java.util.List; public class MainActivity extends AppCompatActivity { private EditText login, password; @@ -35,7 +25,7 @@ public class MainActivity extends AppCompatActivity { if(check.isChecked()){ saveForms(); } - Intent WebA = new Intent(this, WebActivity.class); + Intent WebA = new Intent(this, CabinetActivity.class); WebA.putExtra("login", login.getText().toString()); WebA.putExtra("pass", password.getText().toString()); startActivity(WebA); diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java b/app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java index c513c2a..1f0f0ab 100644 --- a/app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java +++ b/app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java @@ -21,10 +21,10 @@ public class OldParser { m.appendTail(buf); return buf; } - - public ArrayList parseGroup(){ - return null; - } +// +// public ArrayList parseGroup(){ +// return null; +// } public String cutLine(String a, String b, String Line){ if(Line.contains(a)) Line = Line.substring(Line.indexOf(a)+ a.length()); diff --git a/app/src/main/res/layout/app_bar_web.xml b/app/src/main/res/layout/app_bar_web.xml index 10e59f7..f9674cb 100644 --- a/app/src/main/res/layout/app_bar_web.xml +++ b/app/src/main/res/layout/app_bar_web.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="ru.defend.defdevteam.tstu.WebActivity" + tools:context="ru.defend.defdevteam.tstu.CabinetActivity" android:visibility="visible">