Skip to content

Commit

Permalink
rees
Browse files Browse the repository at this point in the history
  • Loading branch information
reesdela committed Oct 26, 2018
0 parents commit b5da1ec
Show file tree
Hide file tree
Showing 39 changed files with 1,014 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.puffs.juby.easyschedule"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('/Users/reesdelahoussaye/Downloads/jsoup-1.11.3.jar')
}
Binary file not shown.
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.puffs.juby.easyschedule;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.puffs.juby.easyschedule", appContext.getPackageName());
}
}
22 changes: 22 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.puffs.juby.easyschedule">
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
154 changes: 154 additions & 0 deletions app/src/main/java/com/puffs/juby/easyschedule/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package com.puffs.juby.easyschedule;

import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Handler;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.openqa.selenium.WebDriver;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class MainActivity extends AppCompatActivity
{
private WebView webView;
private String sClass;
private String courseNum;
private String section;
private String begin;
private String end;
private String days;
private String building;
private String Room;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
}

public void submitInfo(View view) throws InterruptedException, IOException
{

EditText txt = (EditText) findViewById(R.id.pass_edit);
Editable edit = txt.getText();
final String pass = edit.toString();

txt = (EditText) findViewById(R.id.user_edit);
edit = txt.getText();
final String user = edit.toString();

//webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.addJavascriptInterface(new MyJavaScriptInterface(), "HtmlHandler");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
if(url.equals("https://myproxy01.apps.lsu.edu/reg%5CSchedule.nsf/SRRVSCH"))
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
webView.evaluateJavascript("javascript:window.HtmlHandler.handleHtml" +
"('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');", null);
}
}, 8000);

}

}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}

public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
}
});

webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress)
{
if(progress == 100)
{
if(view.getUrl().equals("https://sso.paws.lsu.edu/login"))
{
webView.evaluateJavascript("javascript:(function(){document.getElementById('username').value ='"
+ user
+ "';document.getElementById('password').value ='"
+ pass + "';document.getElementById('LoginButton').click();})()",null);
}
}
}
});

webView.loadUrl("https://sso.paws.lsu.edu/login");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
webView.loadUrl("https://myproxy01.apps.lsu.edu/reg%5CSchedule.nsf/SRRVSCH");
}
}, 8000);




}

private class MyJavaScriptInterface {
@JavascriptInterface
public void handleHtml(String html) {
// Use jsoup on this String here to search for your content.
Document doc = Jsoup.parse(html);

// Now you can, for example, retrieve a div with id="username" here
Elements elements = doc.getElementsByTag("font");
int steps = 1;
for(int i = 26; elements.get(i).equals("Total Hours"))
{
if(elements.get(i).hasText())
{
switch (steps)
{
case 1: sClass = elements.get(i).text();
steps++;
break;
case 2: courseNum = elements.get(i).text();
steps++;
break;
}
}
}
}
}
}


Loading

0 comments on commit b5da1ec

Please sign in to comment.