Skip to content
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

Fix runtime crash #620

Merged
merged 8 commits into from
Aug 31, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/android-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

# Run unit tests
- name: Run Unit Tests
run: ./gradlew testDebugUnitTest
run: ./gradlew testDebugUnitTest --warning-mode all --stacktrace

# If tests pass, generate and upload APK
generate-apk:
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:

- name: Install ktlint
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.1/ktlint
chmod a+x ktlint
sudo mv ktlint /usr/local/bin/

Expand Down
84 changes: 44 additions & 40 deletions PennMobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,64 +41,68 @@ android {
}

dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:3.0-alpha-1'

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation(platform("com.google.firebase:firebase-bom:31.5.0"))

implementation 'com.google.firebase:firebase-analytics'
implementation("com.google.firebase:firebase-crashlytics")
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.5.3'
androidTestImplementation 'org.testng:testng:7.8.0'

implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.maps:google-maps-services:2.2.0'
implementation 'org.jsoup:jsoup:1.16.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.6'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'joda-time:joda-time:2.12.5'
implementation 'org.apache.commons:commons-lang3:3.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:3.0-alpha-1'

implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
implementation 'androidx.annotation:annotation:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation ("androidx.lifecycle:lifecycle-extensions:2.2.0@aar") {
transitive = true
}
implementation 'com.squareup.retrofit:retrofit:1.9.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
implementation 'androidx.browser:browser:1.5.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation 'androidx.exifinterface:exifinterface:1.3.6'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'com.airbnb.android:lottie:5.2.0'
implementation 'com.daimajia.swipelayout:library:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.6.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'org.testng:testng:7.8.0'
implementation 'com.github.Dimezis:BlurView:version-2.0.5'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.ahorn:android-rss:master-SNAPSHOT'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'com.eightbitlab:supportrenderscriptblur:1.0.2'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'com.github.searchy2:CustomAlertViewDialogue:2.6.1'
implementation 'com.airbnb.android:lottie:5.2.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation('com.github.searchy2:CustomAlertViewDialogue:2.6.0'){
exclude group: 'com.eightbitlab', module: 'blurview'
}
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.6.0'
implementation 'com.google.maps:google-maps-services:2.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.5.3'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit:retrofit:1.9.0'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'joda-time:joda-time:2.12.5'
implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'org.jsoup:jsoup:1.16.2'
implementation("com.google.firebase:firebase-crashlytics")

implementation(platform("com.google.firebase:firebase-bom:31.5.0"))

testImplementation 'junit:junit:4.13.2'
}

String getPlatformClientID() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,31 @@ class AboutFragment : Fragment() {
if (gif is AnimatedVectorDrawable) {
gif.start()
} else {
Glide.with(this).asGif().load(R.drawable.logo_gif_transparent).listener(
object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
isFirstResource: Boolean,
): Boolean {
return false
}
Glide
.with(this)
.asGif()
.load(R.drawable.logo_gif_transparent)
.listener(
object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
isFirstResource: Boolean,
): Boolean = false

override fun onResourceReady(
resource: GifDrawable,
model: Any,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
dataSource: DataSource,
isFirstResource: Boolean,
): Boolean {
resource.setLoopCount(1)
return false
}
},
).into(binding.logoGifIv)
override fun onResourceReady(
resource: GifDrawable,
model: Any,
target: com.bumptech.glide.request.target.Target<GifDrawable>?,
dataSource: DataSource,
isFirstResource: Boolean,
): Boolean {
resource.setLoopCount(1)
return false
}
},
).into(binding.logoGifIv)
}

binding.ourTeamRv.layoutManager = GridLayoutManager(context, 3)
Expand Down Expand Up @@ -103,7 +105,8 @@ class AboutFragment : Fragment() {
binding.licensesBtn.setOnClickListener {
val webView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_licenses, null) as WebView
webView.loadUrl("file:///android_asset/open_source_licenses.html")
AlertDialog.Builder(mActivity, R.style.AppTheme_AppBarOverlay_Light)
AlertDialog
.Builder(mActivity, R.style.AppTheme_AppBarOverlay_Light)
.setTitle(getString(R.string.action_licenses))
.setView(webView)
.setPositiveButton(android.R.string.ok, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ class BookGsrFragment : Fragment() {
emailEt.setText(email)

submit.setOnClickListener {
if (firstNameEt.text.toString().matches("".toRegex()) || lastNameEt.text.toString().matches("".toRegex()) ||
if (firstNameEt.text.toString().matches("".toRegex()) ||
lastNameEt.text.toString().matches("".toRegex()) ||
emailEt.text.toString().matches("".toRegex())
) {
Toast.makeText(
activity,
"Please fill in all fields before booking",
Toast.LENGTH_LONG,
).show()
Toast
.makeText(
activity,
"Please fill in all fields before booking",
Toast.LENGTH_LONG,
).show()
} else if (!emailEt.text.toString().matches("""\w+@(seas\.|sas\.|wharton\.|nursing\.)?upenn\.edu""".toRegex())) {
Toast.makeText(activity, "Please enter a valid Penn email", Toast.LENGTH_LONG).show()
} else {
Expand Down Expand Up @@ -142,49 +144,53 @@ class BookGsrFragment : Fragment() {
Log.i("BookGSRFragment", "ID $roomId")
Log.i("BookGSRFragment", "Room Name $roomName")

mStudentLife.bookGSR(
// Passing the values
bearerToken,
startTime,
endTime,
gid,
roomId,
roomName,
// Creating an anonymous callback
object : Callback<GSRBookingResult> {
override fun success(
result: GSRBookingResult,
response: Response,
) {
// Displaying the output as a toast and go back to GSR fragment
if (result.getDetail().equals("success")) {
Toast.makeText(activity, "GSR successfully booked", Toast.LENGTH_LONG).show()

// Save user info in shared preferences
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
val editor = sp.edit()
editor.putString(getString(R.string.first_name), firstNameEt.text.toString())
editor.putString(getString(R.string.last_name), lastNameEt.text.toString())
editor.putString(getString(R.string.email_address), emailEt.text.toString())
editor.apply()
} else {
Toast.makeText(activity, "GSR booking failed", Toast.LENGTH_LONG).show()
Log.e("BookGsrFragment", "GSR booking failed with " + result.getError())
try {
mStudentLife.bookGSR(
// Passing the values
bearerToken,
startTime,
endTime,
gid,
roomId,
roomName,
// Creating an anonymous callback
object : Callback<GSRBookingResult> {
override fun success(
result: GSRBookingResult,
response: Response,
) {
// Displaying the output as a toast and go back to GSR fragment
if (result.getDetail().equals("success")) {
Toast.makeText(activity, "GSR successfully booked", Toast.LENGTH_LONG).show()

// Save user info in shared preferences
val sp = PreferenceManager.getDefaultSharedPreferences(activity)
val editor = sp.edit()
editor.putString(getString(R.string.first_name), firstNameEt.text.toString())
editor.putString(getString(R.string.last_name), lastNameEt.text.toString())
editor.putString(getString(R.string.email_address), emailEt.text.toString())
editor.apply()
} else {
Toast.makeText(activity, "GSR booking failed", Toast.LENGTH_LONG).show()
Log.e("BookGsrFragment", "GSR booking failed with " + result.getError())
}
// go back to GSR fragment
binding.loading.loadingPanel.visibility = View.GONE
activity?.onBackPressed()
}
// go back to GSR fragment
binding.loading.loadingPanel.visibility = View.GONE
activity?.onBackPressed()
}

override fun failure(error: RetrofitError) {
// If any error occurred displaying the error as toast
Log.e("BookGSRFragment", "Error booking gsr", error)
Toast.makeText(activity, "An error has occurred. Please try again.", Toast.LENGTH_LONG).show()
binding.loading.loadingPanel.visibility = View.GONE
activity?.onBackPressed()
}
},
)

override fun failure(error: RetrofitError) {
// If any error occurred displaying the error as toast
Log.e("BookGSRFragment", "Error booking gsr", error)
Toast.makeText(activity, "An error has occurred. Please try again.", Toast.LENGTH_LONG).show()
binding.loading.loadingPanel.visibility = View.GONE
activity?.onBackPressed()
}
},
)
} catch (e: Exception) {
e.printStackTrace()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class CampusExpressLoginFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
return inflater.inflate(R.layout.fragment_campus_express_login, container, false)
}
): View? = inflater.inflate(R.layout.fragment_campus_express_login, container, false)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -86,7 +84,8 @@ class CampusExpressLoginFragment : Fragment() {
headerLayout = view.findViewById(R.id.linear_layout)
cancelButton = view.findViewById(R.id.cancel_button)
val uri =
Uri.parse(campusExpressAuthUrl)
Uri
.parse(campusExpressAuthUrl)
.buildUpon()
.appendQueryParameter("response_type", "code")
.appendQueryParameter("client_id", clientID)
Expand Down Expand Up @@ -135,7 +134,8 @@ class CampusExpressLoginFragment : Fragment() {
private fun goToDiningInsights(refresh: Boolean) {
if (refresh) {
val fragment = DiningInsightsFragment()
parentFragmentManager.beginTransaction()
parentFragmentManager
.beginTransaction()
.replace(R.id.campus_express_page, fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack(null)
Expand Down
Loading
Loading