Skip to content

Added few Activities #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
bin/
app/build/
gen/
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
lint.xml
.classpath
.settings
proguard-project.txt
build.xml
.idea/
*.apk
25 changes: 21 additions & 4 deletions app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="GeekWare" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="GeekWare_App-master" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -66,21 +66,38 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/multidex-instrumentation/1.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/multidex/1.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/8.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="multidex-instrumentation-1.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.1.0" level="project" />
<orderEntry type="library" exported="" name="Parse-1.9.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="multidex-1.0.1" level="project" />
<orderEntry type="library" exported="" name="commons-codec-1.4" level="project" />
<orderEntry type="library" exported="" name="play-services-appindexing-8.1.0" level="project" />
<orderEntry type="library" exported="" name="commons-logging-1.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" />
</component>
</module>
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android {
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
Expand All @@ -22,4 +23,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
}
Binary file added app/libs/commons-codec-1.4.jar
Binary file not shown.
Binary file added app/libs/commons-logging-1.1.1.jar
Binary file not shown.
23 changes: 22 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:name=".GeekwareApplication"
Expand All @@ -24,12 +25,32 @@
<activity
android:name=".SignUpActivity"
android:label="@string/title_activity_sign_up" />
<activity
android:name=".SellnbuyActivity"
android:label="SellnbuyActivity" />
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login" />
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home"></activity>
android:label="@string/title_activity_home" />
<activity
android:name=".MylecturesActivity"
android:label="@string/title_activity_mylectures"></activity>
<activity
android:name=".LectNotesActivity"
android:label="@string/title_activity_lect_notes"></activity>
<activity
android:name=".BusActivity"
android:label="@string/title_activity_bus"></activity>
<!--
ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

</application>

</manifest>
127 changes: 127 additions & 0 deletions app/src/main/java/com/geekware/geekware/BrowserProxy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.geekware.geekware;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;


public class BrowserProxy {
HttpClient httpclient = new DefaultHttpClient();
CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();
HttpGet httpget;
HttpResponse response;
HttpEntity entity;
List<Cookie> cookies;
Cookie cookie = null;
private String action1;
final String sendSMSPage = "http://160by2.com/SendSMS?";
final String sendSMSActionPage =
"http://160by2.com/SendSMSAction?hid_exists=yes";
final String loginPage = "http://160by2.com/re-login?";

public BrowserProxy() {
}

public boolean getLoggedIn(String uname, String pwd) throws IOException,
ClientProtocolException {
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
URI uri = null;
uri = URI.create(loginPage + "username=" + uname + "&password=" + pwd);
HttpGet httpget = new HttpGet(uri);
response = httpclient.execute(httpget, localContext);
entity = response.getEntity();
cookies = cookieStore.getCookies();
Cookie cookie = cookies.get(0);
String cookieSet = cookie.getName() + "=" + cookie.getValue();
entity.consumeContent();
fetchAction(cookieSet);

if (isLoggedIn())
return true;
else
return false;
}

private void fetchAction(String cookieSet) throws IOException {

URLConnection conn = new URL(sendSMSPage).openConnection();
conn.setRequestProperty("Cookie", cookieSet);
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
BufferedReader br = new BufferedReader(isr);
String content;
StringBuilder sBuilder = new StringBuilder();
while (true) {
content = br.readLine();
if (content == null)
break;
else if (content.contains("id=\"action1\"")) {
sBuilder.append(content);
break;
}
}
String action[] = content.split("value=\"");
String action1[] = action[1].split("\"");
setAction1(action1[0]);
}

public void sendSms(String to, String msg) throws URISyntaxException,
UnsupportedEncodingException,
IOException,
ClientProtocolException {

URI uri = null;
msg = URLEncoder.encode(msg, "utf-8");
String params =
"&action1=" + getAction1() + "&mobile1=" + to + "&msg1=" + msg;
uri = new URI(sendSMSActionPage + params);
httpget = new HttpGet(uri);
httpclient.execute(httpget, localContext);
}

public boolean isLoggedIn() {
try {
if (cookies.size() == 2)
return true;
else
return false;

} catch (NullPointerException e) {
return false;
}
}

public void setAction1(String action1) {
this.action1 = action1;
}

public String getAction1() {
return action1;
}



}
Loading