Skip to content

Commit

Permalink
Merge branch 'master' into Test
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay7178 authored Jul 30, 2024
2 parents a8e4ced + 709df83 commit 40a9def
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 119 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/android.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
- name: Rename signed apk
run: |
cd app/build/outputs/apk/release
mv app-release-unsigned-signed.apk vtop_chennai_${{ github.ref_name }}.apk
mv app-release-unsigned-signed.apk vtop_ap_${{ github.ref_name }}.apk
- name: Upload signed apk
uses: softprops/action-gh-release@v1
with:
files: app/build/outputs/apk/release/vtop_chennai_${{ github.ref_name }}.apk
files: app/build/outputs/apk/release/vtop_ap_${{ github.ref_name }}.apk
24 changes: 7 additions & 17 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
{
"project_info": {
"project_number": "539771298090",
"project_id": "vit-student",
"storage_bucket": "vit-student.appspot.com"
"project_number": "887863822131",
"project_id": "android-vtop-vitap",
"storage_bucket": "android-vtop-vitap.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:539771298090:android:a6eb9db58d10b87547fe53",
"mobilesdk_app_id": "1:887863822131:android:3675c69c4ebe191638a046",
"android_client_info": {
"package_name": "tk.therealsuji.vtopchennai"
}
},
"oauth_client": [
{
"client_id": "539771298090-jck5f90j4h8lqd0rfhfbitu4oec0rtqo.apps.googleusercontent.com",
"client_type": 3
}
],
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCqiSXHMOq1ty-4adzcFDchAI6ziiQYRnY"
"current_key": "AIzaSyCOdRn8KY1Va6mvftjlPTXVReMKDlLgaXw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "539771298090-jck5f90j4h8lqd0rfhfbitu4oec0rtqo.apps.googleusercontent.com",
"client_type": 3
}
]
"other_platform_oauth_client": []
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@
import tk.therealsuji.vtopchennai.receivers.TimetableNotificationReceiver;

public class SettingsRepository {
public static final String APP_BASE_URL = "https://vtopchennai.therealsuji.tk";
public static final String APP_BASE_URL = "https://vitstudent.sanjaydev.site";
public static final String APP_ABOUT_URL = APP_BASE_URL + "/about.json";
public static final String APP_PRIVACY_URL = APP_BASE_URL + "/privacy-policy";
public static final String APP_PRIVACY_URL = "https://vtopchennai.therealsuji.tk" + "/privacy-policy";

public static final String DEVELOPER_BASE_URL = "https://therealsuji.tk";
public static final String DEVELOPER_BASE_URL = "https://sanjay7178.github.io";

public static final String GITHUB_BASE_URL = "https://github.com/therealsujitk/android-vtop-chennai";
public static final String GITHUB_BASE_URL = "https://github.com/sanjay7178/android-vtop-vitap";
public static final String GITHUB_FEATURE_URL = GITHUB_BASE_URL + "/issues";
public static final String GITHUB_ISSUE_URL = GITHUB_BASE_URL + "/issues";

Expand All @@ -92,6 +92,7 @@ public class SettingsRepository {
public static final int NOTIFICATION_ID_EXAMS = 1;
public static final int NOTIFICATION_ID_TIMETABLE = 2;
public static final int NOTIFICATION_ID_VTOP_DOWNLOAD = 3;
public static final int NOTIFICATION_REFRESH_PAGE = 8 ;

public static int getTheme(Context context) {
String appearance = getSharedPreferences(context).getString("appearance", "system");
Expand Down
133 changes: 63 additions & 70 deletions app/src/main/java/tk/therealsuji/vtopchennai/services/VTOPService.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
*/
@SuppressLint("SetJavaScriptEnabled")
private void createWebView() {
NotificationCompat.Builder notification;
NotificationManager notificationManager ;
this.webView = new WebView(getApplicationContext());
this.webView.addJavascriptInterface(this, "Android");
this.webView.getSettings().setJavaScriptEnabled(true);
Expand All @@ -177,14 +179,19 @@ public void onPageFinished(WebView view, String url) {
* "page_type": "LANDING"|"HOME"|"LOGIN"
* }
*/
view.evaluateJavascript("(function() {" +
view.evaluateJavascript( "(function() {" +
"const response = {" +
" page_type: 'LANDING'" +
" page_type: \"LANDING\"" +
"};" +
"if ($('input[id=\"authorizedIDX\"]').length === 1) {" +
" response.page_type = 'HOME';" +
"} if ($('form[id=\"vtopLoginForm\"]').length === 1) {" +
" response.page_type = 'LOGIN';" +
" response.page_type = \"HOME\";" +
"}" +
"if ($('form[id=\"vtopLoginForm\"]').length === 1) {" +
" if ($('#recaptcha > div > div.grecaptcha-error').length > 0) {" +
" response.page_type = \"ERRORCATPCHA\";" +
" } else {" +
" response.page_type = \"LOGIN\";" +
" }" +
"}" +
"return response;" +
"})();", responseString -> {
Expand All @@ -193,6 +200,18 @@ public void onPageFinished(WebView view, String url) {
String pageType = response.getString("page_type");

switch (pageType) {
case "ERRORCATPCHA":
if (counter >= 10) {
error(101, "Couldn't connect to the server.");
endService(true);
return;
}

openSignIn();
++counter;

pageState = PageState.LANDING;
break;
case "LANDING":
if (counter >= 10) {
error(101, "Couldn't connect to the server.");
Expand Down Expand Up @@ -360,6 +379,7 @@ private void openSignIn() {
/**
* Function to get the type of captcha (Default Captcha / Google reCaptcha).
*/

private void getCaptchaType() {
/*
* JSON response format
Expand Down Expand Up @@ -1651,71 +1671,44 @@ private void downloadExamSchedule() {
"var data = 'semesterSubId=' + '" + semesterID + "' + '&authorizedID=' + $('#authorizedIDX').val() + '&_csrf=' + $('input[name=\"_csrf\"]').val();" +
"var response = {};" +
"$.ajax({" +
" type: 'POST'," +
" url: 'examinations/doSearchExamScheduleForStudent'," +
" data: data," +
" async: false," +
" success: function(res) {" +
" if(res.toLowerCase().includes('not found')) {" +
" return;" +
" }" +
" var doc = new DOMParser().parseFromString(res, 'text/html');" +
" var slotIndex, dateIndex, timingIndex, venueIndex, locationIndex, numberIndex;" +
" var columns = doc.getElementsByTagName('tr')[0].getElementsByTagName('td');" +
" for (var i = 0; i < columns.length; ++i) {" +
" var heading = columns[i].innerText.toLowerCase();" +
" if (heading.includes('slot')) {" +
" slotIndex = i;" +
" } else if (heading.includes('date')) {" +
" dateIndex = i;" +
" } else if (heading.includes('exam') && heading.includes('time')) {" +
" timingIndex = i;" +
" } else if (heading.includes('venue')) {" +
" venueIndex = i;" +
" } else if (heading.includes('location')) {" +
" locationIndex = i;" +
" } else if (heading.includes('seat') && heading.includes('no.')) {" +
" numberIndex = i;" +
" }" +
" }" +
" var examTitle = '', exam = {}, cells = doc.getElementsByTagName('td');" +
" for (var i = columns.length; i < cells.length; ++i) {" +
" if (cells[i].colSpan > 1) {" +
" examTitle = cells[i].innerText.trim();" +
" response[examTitle] = [];" +
" continue;" +
" }" +
" var index = (i - Object.keys(response).length) % columns.length;" +
" if (index == slotIndex) {" +
" exam.slot = cells[i].innerText.trim().split('+')[0];" +
" } else if (index == dateIndex) {" +
" var date = cells[i].innerText.trim().toUpperCase();" +
" exam.date = date == '' ? null : date;" +
" } else if (index == timingIndex) {" +
" var timings = cells[i].innerText.trim().split('-');" +
" if (timings.length == 2) {" +
" exam.start_time = timings[0].trim();" +
" exam.end_time = timings[1].trim();" +
" } else {" +
" exam.start_time = null;" +
" exam.end_time = null;" +
" }" +
" } else if (index == venueIndex) {" +
" var venue = cells[i].innerText.trim();" +
" exam.venue = venue.replace(/-/g,'') == '' ? null : venue;" +
" } else if (index == locationIndex) {" +
" var location = cells[i].innerText.trim();" +
" exam.seat_location = location.replace(/-/g,'') == '' ? null : location;" +
" } else if (index == numberIndex) {" +
" var number = cells[i].innerText.trim();" +
" exam.seat_number = number.replace(/-/g,'') == '' ? null : parseInt(number);" +
" }" +
" if (Object.keys(exam).length == 7) {" +
" response[examTitle].push(exam);" +
" exam = {};" +
" }" +
" }" +
" }" +
"type: 'POST'," +
"url: 'examinations/doSearchExamScheduleForStudent'," +
"data: data," +
"async: false," +
"success: function(res) {" +
"if(res.toLowerCase().includes('not found')) {" +
"return;" +
"}" +
"var doc = new DOMParser().parseFromString(res, 'text/html');" +
"const table = doc.querySelector('.customTable');" +
"const rows = table.querySelectorAll('tr.tableContent');" +
"let result = {};" +
"let currentExamType = '';" +
"function extractSlot(slotText) {" +
"return slotText.split('+')[0];" +
"}" +
"rows.forEach(row => {" +
"if (row.querySelector('.panelHead-secondary')) {" +
"currentExamType = row.textContent.trim();" +
"result[currentExamType] = [];" +
"} else {" +
"const cells = row.querySelectorAll('td');" +
"if (cells.length >= 13) {" +
"const examData = {" +
"slot: extractSlot(cells[5].textContent.trim())," +
"date: cells[6].textContent.trim()," +
"start_time: cells[9].textContent.split('-')[0].trim()," +
"end_time: cells[9].textContent.split('-')[1].trim()," +
"venue: cells[10].textContent.trim()," +
"seat_location: cells[11].textContent.trim()," +
"seat_number: parseInt(cells[12].textContent.trim())" +
"};" +
"result[currentExamType].push(examData);" +
"}" +
"}" +
"});" +
"response = result;" +
"}" +
"});" +
"return response;" +
"})();", responseString -> {
Expand Down

0 comments on commit 40a9def

Please sign in to comment.