Skip to content
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
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Windows batch scripts break if checked out with LF endings.
# This overrides core.autocrlf=input, which would otherwise strip the CRLFs.
*.bat text eol=crlf

# Unix shell scripts must stay LF, even for contributors on Windows
# with core.autocrlf=true. CRLF here breaks the shebang under sh/CI/Docker.
gradlew text eol=lf
*.sh text eol=lf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ captures/
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json
app/google-services.json

# Freeline
freeline.py
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

54 changes: 29 additions & 25 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'

android {
compileSdk 34
compileSdk 37
defaultConfig {
applicationId "com.cornellappdev.coursegrab"
minSdkVersion 23
minSdkVersion 24
targetSdkVersion 34
versionCode 10
versionName "1.2.0"
Expand All @@ -28,39 +28,43 @@ android {
}
}
compileOptions {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildFeatures {
viewBinding true
buildConfig true
}
namespace 'com.cornellappdev.coursegrab'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation platform('com.google.firebase:firebase-bom:34.18.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-auth'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.firebaseui:firebase-ui-auth:8.0.0'
implementation 'com.google.android.gms:play-services-auth:20.0.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.firebaseui:firebase-ui-auth:9.1.1'
// Pinned: play-services-auth 22.0.0 removed GoogleSignIn/GoogleSignInClient.
// Unpin once LoginActivity/SettingsActivity move to Credential Manager.
implementation 'com.google.android.gms:play-services-auth:21.3.0'
implementation 'com.squareup.okhttp3:okhttp:5.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0'
implementation 'com.google.code.gson:gson:2.14.0'
implementation 'androidx.appcompat:appcompat:1.8.0'
implementation 'androidx.core:core-ktx:1.19.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
implementation 'androidx.recyclerview:recyclerview:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.14.0'
}
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cornellappdev.coursegrab">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.cornellappdev.coursegrab.databinding.ActivityCourseDetailsBinding
import com.cornellappdev.coursegrab.models.ApiResponse
import com.cornellappdev.coursegrab.models.Course
import com.cornellappdev.coursegrab.models.SearchResult
Expand All @@ -20,14 +21,14 @@ import com.cornellappdev.coursegrab.networking.Request
import com.cornellappdev.coursegrab.networking.addTracking
import com.cornellappdev.coursegrab.networking.removeTracking
import com.google.gson.reflect.TypeToken
import kotlinx.android.synthetic.main.activity_course_details.*
import kotlinx.android.synthetic.main.activity_search.back_btn
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class CourseDetailsActivity : AppCompatActivity() {
private lateinit var binding: ActivityCourseDetailsBinding

private lateinit var sectionsRecyclerView: RecyclerView
private lateinit var sectionsViewAdapter: RecyclerView.Adapter<*>
private lateinit var sectionsViewManager: RecyclerView.LayoutManager
Expand All @@ -38,26 +39,27 @@ class CourseDetailsActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_course_details)
binding = ActivityCourseDetailsBinding.inflate(layoutInflater)
setContentView(binding.root)

val courseDetails: SearchResult = intent.getParcelableExtra<SearchResult>("courseDetails") as SearchResult

header_textView.text = "${courseDetails.subject_code} ${courseDetails.course_num}"
binding.headerTextView.text = "${courseDetails.subject_code} ${courseDetails.course_num}"

course_title.text = courseDetails.title
course_details.text =
binding.courseTitle.text = courseDetails.title
binding.courseDetails.text =
if (courseDetails.sections.isNotEmpty()) courseDetails.sections.first().instructors.first() else "To Be Assigned"

// Available Courses Adapter
sectionsViewManager = LinearLayoutManager(this@CourseDetailsActivity)
sectionsViewAdapter = SectionAdapter(courseDetails.sections, this@CourseDetailsActivity)

sectionsRecyclerView = sections_recyclerview.apply {
sectionsRecyclerView = binding.sectionsRecyclerview.apply {
layoutManager = sectionsViewManager
adapter = sectionsViewAdapter
}

back_btn.setOnClickListener { finish() }
binding.backBtn.setOnClickListener { finish() }
}

fun addCourse(courseId: Int, context: Context) {
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/java/com/cornellappdev/coursegrab/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.cornellappdev.coursegrab.databinding.ActivityLoginBinding
import com.cornellappdev.coursegrab.models.ApiResponse
import com.cornellappdev.coursegrab.models.Course
import com.cornellappdev.coursegrab.models.UserSession
Expand All @@ -20,14 +21,13 @@ import com.google.android.gms.common.api.ApiException
import com.google.android.material.snackbar.Snackbar
import com.google.firebase.messaging.FirebaseMessaging
import com.google.gson.reflect.TypeToken
import kotlinx.android.synthetic.main.activity_login.login_rootView
import kotlinx.android.synthetic.main.activity_login.sign_in_button
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class LoginActivity : AppCompatActivity() {
private lateinit var binding: ActivityLoginBinding
private lateinit var googleSignInClient: GoogleSignInClient
private val RC_SIGN_IN = 10032

Expand All @@ -37,7 +37,8 @@ class LoginActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)

if (preferencesHelper.expiresAt > System.currentTimeMillis() / 1000L) {
val intent = Intent(this@LoginActivity, MainActivity::class.java)
Expand Down Expand Up @@ -72,7 +73,7 @@ class LoginActivity : AppCompatActivity() {

googleSignInClient = GoogleSignIn.getClient(this, gso)

sign_in_button.setOnClickListener { signIn() }
binding.signInButton.setOnClickListener { signIn() }
}

private fun signIn() {
Expand Down Expand Up @@ -101,9 +102,9 @@ class LoginActivity : AppCompatActivity() {
}

private fun verifySession(userSession: UserSession) {
if (userSession.session_expiration.isNullOrEmpty() ||
userSession.session_token.isNullOrEmpty() ||
userSession.update_token.isNullOrEmpty()
if (userSession.session_expiration.isEmpty() ||
userSession.session_token.isEmpty() ||
userSession.update_token.isEmpty()
) return

preferencesHelper.sessionToken = userSession.session_token
Expand All @@ -128,7 +129,7 @@ class LoginActivity : AppCompatActivity() {

CoroutineScope(Dispatchers.Main).launch {
val typeToken = object : TypeToken<ApiResponse<Course>>() {}.type
val response = withContext(Dispatchers.IO) {
withContext(Dispatchers.IO) {
Request.makeRequest<ApiResponse<Course>>(
setNotifs.okHttpRequest(),
typeToken
Expand Down Expand Up @@ -166,7 +167,7 @@ class LoginActivity : AppCompatActivity() {
}
} else {
Snackbar.make(
login_rootView,
binding.loginRootView,
"Please use a @cornell.edu account",
Snackbar.LENGTH_LONG
).show()
Expand Down
Loading