Browse Source

WebActivity -> CabinetActivity; Breaking the dependence between the methods!

master
Defend 8 years ago
parent
commit
c72e3d30fa
  1. 2
      app/src/main/AndroidManifest.xml
  2. 33
      app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java
  3. 9
      app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java
  4. 12
      app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java
  5. 8
      app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java
  6. 2
      app/src/main/res/layout/app_bar_web.xml
  7. 2
      app/src/main/res/layout/content_cabinet.xml

2
app/src/main/AndroidManifest.xml

@ -18,7 +18,7 @@
</intent-filter>
</activity>
<activity
android:name=".WebActivity"
android:name=".CabinetActivity"
android:label="@string/title_activity_web"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>

33
app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java → 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("<td headers=\\\"BRS\\\"><a href=\\\"","\" title=\\\"Просмотр журналов\\\">",AdditionalHTML);
RateValueURL = "http://web-iais.admin.tstu.ru:7777/zion/" +
parser.cutLine("<td headers=\\\"RTG\\\"><a href=\\\"","\\\" title=\\\"Просмотр успеваемости\\\">",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("><td headers=\\\"GROUP_NAME\\\"><a href=\\\"","\\\">",RateValueHTML);
FacultyRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + parser.cutLine("<td headers=\\\"INST\\\"><a href=\\\"","\\\">", 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<String>() {
@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());
}
}
}

9
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;

12
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);

8
app/src/main/java/ru/defend/defdevteam/tstu/OldParser.java

@ -21,10 +21,10 @@ public class OldParser {
m.appendTail(buf);
return buf;
}
public ArrayList<WebActivity.groupList> parseGroup(){
return null;
}
//
// public ArrayList<CabinetActivity.groupList> parseGroup(){
// return null;
// }
public String cutLine(String a, String b, String Line){
if(Line.contains(a)) Line = Line.substring(Line.indexOf(a)+ a.length());

2
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">
<android.support.design.widget.AppBarLayout

2
app/src/main/res/layout/content_cabinet.xml

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="ru.defend.defdevteam.tstu.WebActivity"
tools:context="ru.defend.defdevteam.tstu.CabinetActivity"
tools:showIn="@layout/app_bar_web"
android:id="@+id/mainLayout">

Loading…
Cancel
Save