commit ee8a10de20a53e2e2791b80d9968768aa9fd43e2 Author: Defend Date: Fri Feb 10 17:05:12 2017 +0300 First commit for the all app diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..a16956c --- /dev/null +++ b/app/app.iml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..3f70650 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + + defaultConfig { + applicationId "ru.defend.defdevteam.tstu" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:design:23.4.0' +} diff --git a/app/libs/jsevaluator-1.0.aar b/app/libs/jsevaluator-1.0.aar new file mode 100644 index 0000000..95c6567 Binary files /dev/null and b/app/libs/jsevaluator-1.0.aar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..6583f9c --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Users\nikit_000\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6f13a57 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java b/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java new file mode 100644 index 0000000..33125b4 --- /dev/null +++ b/app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java @@ -0,0 +1,89 @@ +package ru.defend.defdevteam.tstu; + +import android.app.Activity; +import android.widget.TextView; + +/** + * Created by thedefend on 29.11.16. + */ + +public class FeedController { + + FeedReader feedReader; + FeedUpdater feedUpdater; + String newsFeed; + int updateRate; //in minutes + private WebActivity activity; + + public FeedController(WebActivity activity, int updateRate) { + this(activity, updateRate, "http://press.tstu.ru/?format=feed"); + } + + public FeedController(WebActivity activity, int updateRate, String rssUrl) { + feedReader = new FeedReader(this, rssUrl); + feedUpdater = new FeedUpdater(); + this.activity = activity; + this.updateRate = updateRate; + feedUpdater.start(); + } + + private void startFeedReader() { + switch (feedReader.getThreadState()) { + case THREAD_FAIL: + feedReader.start(); + break; + case THREAD_NULL: + feedReader.start(); + break; + } + } + + private boolean checkFeedReader() throws Exception{ + switch (feedReader.getThreadState()) { + case THREAD_COMPLETE: + return true; + case THREAD_NULL: + return false; + default: + throw new Exception("Failed to get rss source string from FeedReader class"); + } + } + + public void feedUpdateAction(final String result) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + activity.newsTextView.setText(result); + } + }); + } + + private class FeedUpdater extends Thread { + @Override + public void run() { + startFeedReader(); + try { + //TODO: вернуть к норме updateRate*60*1000 + sleep(updateRate*60); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public FeedUpdater() { + this.start(); + } + } + + public String getRssString() throws Exception{ + if(checkFeedReader()) { + newsFeed = feedReader.getResult(); + return newsFeed; + } + throw new Exception("Feed Reader returned empty string"); + } + + interface FeedCallback{ + void Callback(); + } +} diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/FeedParser.java b/app/src/main/java/ru/defend/defdevteam/tstu/FeedParser.java new file mode 100644 index 0000000..9b97351 --- /dev/null +++ b/app/src/main/java/ru/defend/defdevteam/tstu/FeedParser.java @@ -0,0 +1,30 @@ +package ru.defend.defdevteam.tstu; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +/** + * Created by thedefend on 29.11.16. + */ + +public class FeedParser { + + FeedParser(String omg) { + try { + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + // Создается дерево DOM документа из файла + Document document = documentBuilder.parse(omg); + + // Получаем корневой элемент + Node root = document.getDocumentElement(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + +} diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/FeedReader.java b/app/src/main/java/ru/defend/defdevteam/tstu/FeedReader.java new file mode 100644 index 0000000..ac195e9 --- /dev/null +++ b/app/src/main/java/ru/defend/defdevteam/tstu/FeedReader.java @@ -0,0 +1,75 @@ +package ru.defend.defdevteam.tstu; + +import android.os.Handler; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; + +/** + * Created by thedefend on 28.11.16. + */ + +public class FeedReader extends Thread implements FeedController.FeedCallback { + + private String link; + private String result; + private FeedController feedController; + public enum States { + THREAD_NULL, + THREAD_WORK, + THREAD_FAIL, + THREAD_COMPLETE + } + private States threadState; + + FeedReader (FeedController feedController, String link) { + this.link = link; + this.feedController = feedController; + this.threadState = States.THREAD_NULL; + } + + + public void run(){ + try { + this.threadState = States.THREAD_WORK; + this.result = getRss(link); + this.threadState = States.THREAD_COMPLETE; + //TODO: слишком сильная взаимосвязь с управляющим классом + feedController.feedUpdateAction(result); + } catch (Exception e) { + this.threadState = States.THREAD_FAIL; + e.printStackTrace(); + } + + } + + private String getRss(String link) throws Exception { + String tempString = null; + String inputString = ""; + URL rssFeed = new URL(link); + BufferedReader inputStream = new BufferedReader( + new InputStreamReader(rssFeed.openStream())); + + do { + if(tempString != null) { + inputString += tempString; + } + tempString = inputStream.readLine(); + } while (tempString != null); + + return inputString; + } + + public States getThreadState() { + return this.threadState; + } + + public String getResult() { + return this.result; + } + + public void Callback(){ + + } +} diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java b/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java new file mode 100644 index 0000000..d5b9e5f --- /dev/null +++ b/app/src/main/java/ru/defend/defdevteam/tstu/MainActivity.java @@ -0,0 +1,140 @@ +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; + public ImageView logo; + private SharedPreferences sPref; + final String LOGIN = "login"; + final String PASSWORD = "password"; + final String CHECK = "check"; + public CheckBox check; + static public List subs; + + + + public void authButtonOnClick(View v){ + if(check.isChecked()){ + saveForms(); + } + Intent WebA = new Intent(this, WebActivity.class); + WebA.putExtra("login", login.getText().toString()); + WebA.putExtra("pass", password.getText().toString()); + startActivity(WebA); + //onFeedReaderComplete(); + } + + //TODO: Проверка авторизации здеся, хотя как ее тут пилить, когда ее нету лооол! + void saveForms() { + sPref = getPreferences(MODE_PRIVATE); + SharedPreferences.Editor ed = sPref.edit(); + ed.putString(LOGIN, login.getText().toString()); + ed.putString(PASSWORD, password.getText().toString()); + ed.putBoolean(CHECK, check.isChecked()); + ed.apply(); + } + + void loadForms() { + sPref = getPreferences(MODE_PRIVATE); + login.setText(sPref.getString(LOGIN, "")); + password.setText(sPref.getString(PASSWORD, "")); + check.setChecked(sPref.getBoolean(CHECK, false)); + } + + public void updateForms(View v){ + if(!check.isChecked()) { + password.setText(""); + saveForms(); + } + else { + saveForms(); + } + } + + + public class subsAdapter extends ArrayAdapter { + public subsAdapter(Context context) { + super(context, android.R.layout.simple_list_item_multiple_choice, subs); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + groupList group = getItem(position); + + if(convertView == null){ + convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_multiple_choice, null); + } + ((TextView) convertView.findViewById(android.R.id.text1)).setText(group.name); + return convertView; + } + } + + + + public class groupList { + public String name, rate; + public groupList(String name, String rate){ + this.name = name; + this.rate = rate; + } + } + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + login = (EditText) findViewById(R.id.editLogin); + password = (EditText) findViewById(R.id.passEdit); + check = (CheckBox) findViewById(R.id.save); + loadForms(); + //TODO: убрать потом + subs = new ArrayList(); + subs.add(new groupList("test","test")); + subs.add(new groupList("test","test")); + subs.add(new groupList("test","test")); + subs.add(new groupList("test","test")); + setContentView(R.layout.subscriptions); + ArrayAdapter subsL = new subsAdapter(this); + ListView subsList = (ListView) findViewById(R.id.subsList); + subsList.setAdapter(subsL); + } + + @Override + protected void onResume() { + super.onResume(); + Intent intent = getIntent(); + if (!(intent.getStringExtra("error") == null)) { + Log.i("TESTINGG", intent.getStringExtra("error")); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if(check.isChecked()) saveForms(); + } + + public void OnSubsListClick(View v) { + + } +} diff --git a/app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java b/app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java new file mode 100644 index 0000000..cef5676 --- /dev/null +++ b/app/src/main/java/ru/defend/defdevteam/tstu/WebActivity.java @@ -0,0 +1,550 @@ +package ru.defend.defdevteam.tstu; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.support.design.widget.NavigationView; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; +import android.view.ViewGroup; +import android.webkit.ValueCallback; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ArrayAdapter; +import android.widget.Chronometer; +import android.widget.ListView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class WebActivity extends AppCompatActivity + implements NavigationView.OnNavigationItemSelectedListener { + + + public WebView browser; + public WebSettings browserSet; + static public String AuthURL, MainURL, AdditionalURL ,JournalURL, RateValueURL, GroupRateURL, + FacultyRateURL, siteBuf; + static public String MainHTML, AdditionalHTML, JournalHTML, RateValueHTML, GroupRateHTML, + FacultyRateHTML; + boolean authBegin,taskFinished = false; + public TextView studentName, studentGroup, studentRate, positionGroup, + positionFaculty, newsTextView; + public RelativeLayout profileLayout, journalLayout, gRateLayout, + fRateLayout, aboutLayout, progressLayout, newsLayout; + public Toolbar myToolbar; + public Chronometer timer; + static public List group, faculty, subs; + Intent MainA; + FeedController feedController; + + + public class groupList { + public String name, rate; + public groupList(String name, String rate){ + this.name = name; + this.rate = rate; + } + } + + public class groupAdapter extends ArrayAdapter { + public groupAdapter(Context context){ + super(context, android.R.layout.simple_list_item_2, group); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent){ + groupList group = getItem(position); + + if (convertView == null){ + convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_2, null); + } + + ((TextView) convertView.findViewById(android.R.id.text1)).setText(group.name); + ((TextView) convertView.findViewById(android.R.id.text2)).setText(group.rate); + + return convertView; + } + + } + + public class subsAdapter extends ArrayAdapter { + public subsAdapter(Context context) { + super(context, android.R.layout.simple_selectable_list_item); + } + + @NonNull + @Override + public View getView(int position, View convertView, ViewGroup parent) { + groupList group = getItem(position); + + if(convertView == null){ + convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_selectable_list_item, null); + } + ((TextView) convertView.findViewById(android.R.id.text1)).setText(group.name); + return convertView; + } + } + + public class facultyAdapter extends ArrayAdapter { + public facultyAdapter(Context context){ + super(context, android.R.layout.simple_list_item_2, faculty); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent){ + groupList group = getItem(position); + + if (convertView == null){ + convertView = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_2, null); + } + + ((TextView) convertView.findViewById(android.R.id.text1)).setText(group.name); + ((TextView) convertView.findViewById(android.R.id.text2)).setText(group.rate); + + return convertView; + } + + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.cabinet); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); +// toolbar.setNavigationOnClickListener( +// new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// Log.d("Toolbar","Hmmm..."); +// if(drawer.isDrawerOpen(GravityCompat.START)){ +// drawer.openDrawer(GravityCompat.START); +// } +// } +// }); + toggle.syncState(); + + NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); + navigationView.setNavigationItemSelectedListener(this); + + MainA = getIntent(); + + + + browser = (WebView) findViewById(R.id.webView); + browser.setWebViewClient(new MyWebViewClient()); + browserSet = browser.getSettings(); + browserSet.setJavaScriptEnabled(true); + studentName = (TextView) findViewById(R.id.studentName); + studentRate = (TextView) findViewById(R.id.studentRate); + studentGroup = (TextView) findViewById(R.id.studentGroup); + positionFaculty = (TextView) findViewById(R.id.positionFaculty); + newsTextView = (TextView) findViewById(R.id.newsTextView); + positionGroup = (TextView) findViewById(R.id.positionGroup); + profileLayout = (RelativeLayout) findViewById(R.id.profileLayout); + journalLayout = (RelativeLayout) findViewById(R.id.journalList); + gRateLayout = (RelativeLayout) findViewById(R.id.gRateLayout); + fRateLayout = (RelativeLayout) findViewById(R.id.fRateLayout); + aboutLayout = (RelativeLayout) findViewById(R.id.aboutLayout); + progressLayout = (RelativeLayout) findViewById(R.id.progressLayout); + newsLayout = (RelativeLayout) findViewById(R.id.newsLayout); + progressLayout.setVisibility(View.VISIBLE); + profileLayout.setVisibility(View.VISIBLE); + myToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(myToolbar); + navigationView.getMenu().getItem(1).setChecked(true); + myToolbar.setTitle(R.string.title_profile); + + + feedController = new FeedController(this, 1); + + AuthURL = "http://web-iais.admin.tstu.ru:7777/zion/f?p=stud_main"; + loadSite(); + + } + + @Override + public void onBackPressed() { + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.cabinet, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public boolean onNavigationItemSelected(MenuItem item) { + int id = item.getItemId(); + newsLayout.setVisibility(View.INVISIBLE); + profileLayout.setVisibility(View.INVISIBLE); + journalLayout.setVisibility(View.INVISIBLE); + gRateLayout.setVisibility(View.INVISIBLE); + fRateLayout.setVisibility(View.INVISIBLE); + aboutLayout.setVisibility(View.INVISIBLE); + if(!taskFinished) { + progressLayout.setVisibility(View.VISIBLE); + } + switch (id) { + case R.id.nav_newsfeed: + progressLayout.setVisibility(View.INVISIBLE); + newsLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_newsfeed); + break; + case R.id.nav_profile: + profileLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_profile); + break; + case R.id.nav_journal: + journalLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_journal); + break; + case R.id.nav_grouprate: + gRateLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_grouprate); + break; + case R.id.nav_facultyrate: + fRateLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_globalrate); + break; + case R.id.nav_aboutapp: + progressLayout.setVisibility(View.INVISIBLE); + aboutLayout.setVisibility(View.VISIBLE); + myToolbar.setTitle(R.string.title_about_dev); + break; + case R.id.nav_changeacc: + finish(); + break; + } + DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + drawer.closeDrawer(GravityCompat.START); + return true; + } + + + + public static StringBuffer removeUTFCharacters(String data){ + Pattern p = Pattern.compile("\\\\u(\\p{XDigit}{4})"); + Matcher m = p.matcher(data); + StringBuffer buf = new StringBuffer(data.length()); + while (m.find()) { + String ch = String.valueOf((char) Integer.parseInt(m.group(1), 16)); + m.appendReplacement(buf, Matcher.quoteReplacement(ch)); + } + m.appendTail(buf); + return buf; + } + + public void loadSite () { + browser.loadUrl(AuthURL); + } + + public String cutLine(String a, String b, String Line){ + if(Line.contains(a)) Line = Line.substring(Line.indexOf(a)+ a.length()); + if(Line.contains(b)) { + if(b == ""){ + return Line; + } + Line = Line.substring(0, Line.indexOf(b)); + return Line; + } else { + return ""; + } + } + + public String cutLine(String a, String b, String Line, boolean hard){ + if ((!Line.contains(a)) || (a.equals("")) ) return ""; + if ((!Line.contains(b)) || (b.equals("")) ) return ""; + Line = Line.substring(Line.indexOf(a)+ a.length()); + Line = Line.substring(0, Line.indexOf(b)); + return Line; + } + + + // НЕИЗВЕСТНОЕ ИСКЛЮЧЕНИЕ + public void unknownState(int currentState){ + Log.e("unknownState","Не удалось получить ссылки на странице студента"); + Log.e("unknownState",browser.getUrl()); + finish(); + } + // АВТОРИЗАЦИЯ + public boolean Auth () { + authBegin = true; + String login = MainA.getStringExtra("login"); + String password = MainA.getStringExtra("pass"); + 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+"'}});"); + return true; + } + + public byte sessionState () { + if(taskFinished) return 127; + Intent intent = new Intent(); + Log.i("sessionActive","Checking session"); + String a = cutLine("http://web-iais.admin.tstu.ru:7777/zion/f?p=503:",":",browser.getUrl()); + switch (a){ + case "LOGIN_DESKTOP": + Log.i("sessionActive","Окно авторизации"); + //MainActivity.error.setText("Конец сессии авторизации"); + finish(); + return 0; + case "er": + Log.i("sessionActive","Окно авторизации"); + //MainActivity.error.setText("Ошибка авторизации"); + finish(); + return 1; + case "1": + Log.i("sessionActive","Страница студента"); + intent.putExtra("error","Вход производился успешно"); + MainURL = browser.getUrl(); + taskGenerator(2); + return 2; + case "40": + Log.i("sessionActive","Страница - Успеваемость"); + taskGenerator(3); + return 3; + case "41": + Log.i("sessionActive","Страница - Журналы|Главная"); + taskGenerator(4); + return 4; + case "43": + Log.i("sessionActive","Страница - Рейтинг|Главная"); + String s = cutLine("","503:",MainURL) + "503:43:" + cutLine(":1:","",MainURL)+":"; + if(cutLine(s,":NO:",browser.getUrl()).equals("RATE_GROUP")) { + taskGenerator(6); + return 6; + } + if(cutLine(s,":NO:",browser.getUrl()).equals("RATE_INST")) { + taskGenerator(7); + return 7; + } + taskGenerator(5); + return 5; + + } + return 0; + } + + + // Контент генератор + public void taskGenerator(int state){ + if (!isFinishing()) + switch (state){ + case 2: + MainHTML = siteBuf; + String studNameGroup = cutLine("", + "", + MainHTML); + studentName.setText(cutLine(""," /",studNameGroup)); + studentGroup.setText("Группа: " + cutLine("/ ","",studNameGroup)); + browser.loadUrl("javascript:apex.submit('T_ЗАНЯТИЯ/ОЦЕНКИ');"); + break; + case 3: + AdditionalHTML = siteBuf; + JournalURL = "http://web-iais.admin.tstu.ru:7777/zion/" + + cutLine("",AdditionalHTML); + RateValueURL = "http://web-iais.admin.tstu.ru:7777/zion/" + + cutLine("",AdditionalHTML); + browser.loadUrl(JournalURL); + break; + case 4: + JournalHTML = siteBuf; + browser.loadUrl(RateValueURL); + break; + case 5: + RateValueHTML = siteBuf; + String rate = cutLine("","",RateValueHTML); + studentRate.setText("Балл: " + rate); + GroupRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + cutLine(">",RateValueHTML); + FacultyRateURL = "http://web-iais.admin.tstu.ru:7777/zion/" + cutLine("", RateValueHTML); + browser.loadUrl(GroupRateURL); + break; + case 6: + GroupRateHTML = siteBuf; + fillGroup(); + browser.loadUrl(FacultyRateURL); + break; + case 7: + FacultyRateHTML = siteBuf; + fillFaculty(); + fillAll(); + taskFinished = true; + progressLayout.setVisibility(View.INVISIBLE); + break; + } + + } + + public void fillGroup(){ + group = new ArrayList(); + String n,r; + String gr = siteBuf; + gr = cutLine("

Рейтинг в группе

", "", gr); + int i = 0; + while ( !(cutLine("","",gr,true) == "")){ + Integer s = Integer.valueOf(cutLine("","",gr)); + if(s == (i+1)) { + n = cutLine("", "", gr); + if (!(cutLine("", "", n) == "")) + n = cutLine("", "",n); + r = cutLine("", "", gr); + r += " | Группа: " + cutLine("","", gr, true); + group.add(new groupList(n,"Общий балл: " + r)); + i++; + } + gr = cutLine("\\n", "", gr); + } + ArrayAdapter groupL = new groupAdapter(this); + ListView groupList = (ListView) findViewById(R.id.groupList); + groupList.setAdapter(groupL); + } + + public void fillFaculty(){ + faculty = new ArrayList(); + String n,r; + String fr = siteBuf; + fr = cutLine("

Рейтинг в институте/факультете

", "", fr); + int i = 0; + while ( !(cutLine("","",fr,true) == "")){ + Integer s = Integer.valueOf(cutLine("","",fr)); + if(s == (i+1)) { + n = cutLine("", "", fr); + if (!(cutLine("", "", n) == "")) + n = cutLine("", "",n); + r = cutLine("", "", fr); + r += " | Группа: " + cutLine("","", fr, true); + faculty.add(new groupList(n,"Общий балл: " + r)); + i++; + } + fr = cutLine("\\n", "", fr); + } + ArrayAdapter facultyL = new facultyAdapter(this); + ListView facultyList = (ListView) findViewById(R.id.facultyList); + facultyList.setAdapter(facultyL); + } + + + //TODO: Переделать к хуям позор ниже + public void fillAll(){ + String s; + String s2 = GroupRateHTML; + s = cutLine("","",GroupRateHTML); + s = cutLine("",s); + while (s.equals("")) { + s2 = cutLine("","",s2); + s = cutLine("","",s2); + s = cutLine("",s); + } + s2 = cutLine("","",s2); + Log.i("GroupPos",s2); + positionGroup.setText("Место в группе: " + s2); + s = ""; + s2 = FacultyRateHTML; + s = cutLine("","",FacultyRateHTML); + s = cutLine("",s); + while (s.equals("")) { + s2 = cutLine("","",s2); + s = cutLine("","",s2); + s = cutLine("",s); + } + s2 = cutLine("","",s2); + Log.i("FacultyPos",s2); + positionFaculty.setText("Место в институте: " + s2); + } + + public void buttonRefresh (View v) { + getHTML(); + } + + public void buttonLogout (View v) { + finish(); + } + + @TargetApi(19) + public void getHTML(){ + + browser.evaluateJavascript("javascript:document.documentElement.outerHTML;", new ValueCallback() { + @Override + public void onReceiveValue(String s) { + siteBuf = s; + encodeHTML(); + if(!authBegin) Auth(); + else sessionState(); + } + }); + } + + public void encodeHTML(){ + if(siteBuf != null){ + siteBuf = removeUTFCharacters(siteBuf).toString(); + Log.d("Response html","Загружена страница "+cutLine("","",siteBuf)); + Log.i("encodeHTML",siteBuf); + } + + } + + + private class MyWebViewClient extends WebViewClient { + @Override + public void onPageFinished(WebView view, String url) { + getHTML(); + Log.i("onPageFinished",browser.getUrl()); + } + } +} diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-v21/ic_menu_camera.xml new file mode 100644 index 0000000..0d9ea10 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-v21/ic_menu_gallery.xml new file mode 100644 index 0000000..f6872c4 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-v21/ic_menu_manage.xml new file mode 100644 index 0000000..c1be60b --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_manage.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-v21/ic_menu_send.xml new file mode 100644 index 0000000..00c668c --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_send.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-v21/ic_menu_share.xml new file mode 100644 index 0000000..a28fb9e --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_share.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml new file mode 100644 index 0000000..209aa64 --- /dev/null +++ b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/Thumbs.db b/app/src/main/res/drawable/Thumbs.db new file mode 100644 index 0000000..454f6c0 Binary files /dev/null and b/app/src/main/res/drawable/Thumbs.db differ diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable/logo.png new file mode 100644 index 0000000..c2e2077 Binary files /dev/null and b/app/src/main/res/drawable/logo.png differ diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..8da799d --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/subs_text_bg.xml b/app/src/main/res/drawable/subs_text_bg.xml new file mode 100644 index 0000000..0963c72 --- /dev/null +++ b/app/src/main/res/drawable/subs_text_bg.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_web.xml b/app/src/main/res/layout/app_bar_web.xml new file mode 100644 index 0000000..10e59f7 --- /dev/null +++ b/app/src/main/res/layout/app_bar_web.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/cabinet.xml b/app/src/main/res/layout/cabinet.xml new file mode 100644 index 0000000..beba8f7 --- /dev/null +++ b/app/src/main/res/layout/cabinet.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/app/src/main/res/layout/cabinet_about.xml b/app/src/main/res/layout/cabinet_about.xml new file mode 100644 index 0000000..b11f9cb --- /dev/null +++ b/app/src/main/res/layout/cabinet_about.xml @@ -0,0 +1,44 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_facultylist.xml b/app/src/main/res/layout/cabinet_facultylist.xml new file mode 100644 index 0000000..2e3b7af --- /dev/null +++ b/app/src/main/res/layout/cabinet_facultylist.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_grouplist.xml b/app/src/main/res/layout/cabinet_grouplist.xml new file mode 100644 index 0000000..8b08c76 --- /dev/null +++ b/app/src/main/res/layout/cabinet_grouplist.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_journallist.xml b/app/src/main/res/layout/cabinet_journallist.xml new file mode 100644 index 0000000..954b3bd --- /dev/null +++ b/app/src/main/res/layout/cabinet_journallist.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_newsfeed.xml b/app/src/main/res/layout/cabinet_newsfeed.xml new file mode 100644 index 0000000..d3eb5fa --- /dev/null +++ b/app/src/main/res/layout/cabinet_newsfeed.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_profile.xml b/app/src/main/res/layout/cabinet_profile.xml new file mode 100644 index 0000000..d392595 --- /dev/null +++ b/app/src/main/res/layout/cabinet_profile.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cabinet_progress.xml b/app/src/main/res/layout/cabinet_progress.xml new file mode 100644 index 0000000..6060b2a --- /dev/null +++ b/app/src/main/res/layout/cabinet_progress.xml @@ -0,0 +1,24 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_cabinet.xml b/app/src/main/res/layout/content_cabinet.xml new file mode 100644 index 0000000..269e456 --- /dev/null +++ b/app/src/main/res/layout/content_cabinet.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml new file mode 100644 index 0000000..88a7fd0 --- /dev/null +++ b/app/src/main/res/layout/main.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + +