Skip to content

Commit

Permalink
create new firebase analytics account.
Browse files Browse the repository at this point in the history
- add google-services.json to .gitignore
- update github actions to create google-services.json
- some crashyltics stuff for login
  • Loading branch information
meiron03 committed Dec 15, 2023
1 parent 082e8a8 commit 024d579
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 14 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/android-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
env:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties

# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Run unit tests
- name: Run Unit Tests
run: ./gradlew testDebugUnitTest
Expand Down Expand Up @@ -60,7 +68,14 @@ jobs:
env:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties


# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Generate Signed APK
- name: Generate Release APK
run: ./gradlew assembleRelease
Expand Down Expand Up @@ -108,6 +123,13 @@ jobs:
PLATFORM_REDIRECT_URI: ${{ secrets.PLATFORM_REDIRECT_URI }}
run: echo PLATFORM_REDIRECT_URI=\"$PLATFORM_REDIRECT_URI\" >> ./local.properties

# Create google-services.json
- name: Create google-services.json
run: |
cat << EOF > PennMobile/google-services.json
${{ secrets.GOOGLE_SERVICES_JSON }}
EOF
# Run JaCoCo, generate Test Report
- name: Check Code Coverage
run: ./gradlew jacocoTestReport --stacktrace
Expand All @@ -120,6 +142,7 @@ jobs:
path: PennMobile/build/reports

# Publish to Firebase App Distribution
# https://github.com/wzieba/Firebase-Distribution-Github-Action
deploy-firebase:
needs: generate-apk
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -132,7 +155,7 @@ jobs:
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_TOKEN}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: tester
file: PennMobile-release-unsigned-signed.apk

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gradle/wrapper/

# Local configuration file (sdk path, etc)
local.properties
google-services.json

# Proguard folder generated by Eclipse
proguard/
Expand Down
1 change: 1 addition & 0 deletions PennMobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.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.PhilJay:MPAndroidChart:v3.1.0'
Expand Down
10 changes: 5 additions & 5 deletions PennMobile/google-services.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"project_info": {
"project_number": "86950866683",
"project_id": "pennmobilefbtest",
"storage_bucket": "pennmobilefbtest.appspot.com"
"project_number": "261196915337",
"project_id": "penn-mobile-android",
"storage_bucket": "penn-mobile-android.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:86950866683:android:0b66c19f0e9f40617a4a5e",
"mobilesdk_app_id": "1:261196915337:android:82e48698e3df3cdf3bdc58",
"android_client_info": {
"package_name": "com.pennapps.labs.pennmobile"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDPyjYP8lTQFHt-uy8UBLdKGrGAmHzyhuA"
"current_key": "AIzaSyCavOsfwwY54_dlm_oW4wMDLJgdXghLYP8"
}
],
"services": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.fragment.app.Fragment
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.firebase.analytics.FirebaseAnalytics
import com.pennapps.labs.pennmobile.adapters.HomeAdapter
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.classes.HomeCell
Expand All @@ -32,7 +31,6 @@ import kotlinx.android.synthetic.main.loading_panel.*
import java.util.*
import kotlin.collections.ArrayList


class HomeFragment : Fragment() {

private lateinit var mActivity: MainActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class LoginFragment : Fragment() {

val fragmentManager = mActivity.supportFragmentManager
val gif = R.drawable.login_background
// if (Build.VERSION.SDK_INT > 28 && (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) {
// gif = R.drawable.login_background_dark
// }

Glide.with(this).asGif().load(gif).listener(object : RequestListener<GifDrawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<GifDrawable>?, isFirstResource: Boolean): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import android.widget.LinearLayout
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.api.Platform
import com.pennapps.labs.pennmobile.api.Platform.platformBaseUrl
Expand Down Expand Up @@ -92,7 +94,6 @@ class LoginWebviewFragment : Fragment() {
cancelButton.setOnClickListener {
mActivity.startLoginFragment()
}

}

private fun encryptPassword(password: String) {
Expand Down Expand Up @@ -193,6 +194,9 @@ class LoginWebviewFragment : Fragment() {

override fun success(t: AccessTokenResponse?, response: Response?) {
if (response?.status == 200) {

FirebaseAnalytics.getInstance(mActivity).logEvent("LoginEvent", null)

val accessToken = t?.accessToken
val editor = sp.edit()
editor.putString(getString(R.string.access_token), accessToken)
Expand All @@ -209,6 +213,7 @@ class LoginWebviewFragment : Fragment() {
}

override fun failure(error: RetrofitError) {
FirebaseCrashlytics.getInstance().recordException(error)
Log.e("Accounts", "Error fetching access token $error", error)
Toast.makeText(mActivity, "Error logging in", Toast.LENGTH_SHORT).show()
mActivity.startLoginFragment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import com.pennapps.labs.pennmobile.adapters.MainPagerAdapter
import com.pennapps.labs.pennmobile.api.CampusExpress
import com.pennapps.labs.pennmobile.api.OAuth2NetworkManager
import com.pennapps.labs.pennmobile.api.Platform
import com.pennapps.labs.pennmobile.api.Serializer.*
import com.pennapps.labs.pennmobile.api.StudentLife
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.preference.PreferenceManager
import android.provider.Settings
import android.util.Log
import androidx.lifecycle.lifecycleScope
import com.google.firebase.crashlytics.FirebaseCrashlytics

import com.pennapps.labs.pennmobile.BuildConfig
import com.pennapps.labs.pennmobile.MainActivity
import com.pennapps.labs.pennmobile.R
Expand Down Expand Up @@ -80,6 +82,7 @@ class OAuth2NetworkManager(private var mActivity: MainActivity) {

override fun failure(error: RetrofitError) {

FirebaseCrashlytics.getInstance().recordException(error)
Log.e("Accounts", "Error refreshing access token $error")

if (error.response != null && error.response.status == 400) {
Expand Down

0 comments on commit 024d579

Please sign in to comment.