Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit a1daf87

Browse files
naming style
1 parent dfde7f7 commit a1daf87

File tree

5 files changed

+21
-64
lines changed

5 files changed

+21
-64
lines changed

android/canonical/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies {
3636
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3737
implementation 'androidx.core:core-ktx:1.3.0'
3838
implementation 'androidx.appcompat:appcompat:1.1.0'
39+
implementation "androidx.fragment:fragment-ktx:1.2.5"
3940
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
4041
implementation 'com.google.android.gms:play-services-auth:18.0.0'
4142
implementation 'com.google.android.material:material:1.1.0'

android/canonical/app/google-services.json

Lines changed: 0 additions & 48 deletions
This file was deleted.

android/canonical/app/src/main/java/com/google/samples/quickstart/canonical/MainActivity.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ import com.google.firebase.auth.FirebaseAuth
1515
import com.google.firebase.auth.GoogleAuthProvider
1616

1717
class MainActivity : AppCompatActivity() {
18-
lateinit var mGoogleSignInClient: GoogleSignInClient
18+
lateinit var googleSignInClient: GoogleSignInClient
1919
private lateinit var auth: FirebaseAuth
20-
private val tag = "MainActivity-Login"
21-
private val firebaseTag = "MainActivity-Login"
2220

2321
private fun googleSignInInit() {
2422
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
2523
.requestIdToken(getString(R.string.default_web_client_id))
2624
.requestEmail()
2725
.build()
2826

29-
mGoogleSignInClient = GoogleSignIn.getClient(this, gso)
27+
googleSignInClient = GoogleSignIn.getClient(this, gso)
3028
}
3129

3230
private fun signIn() {
3331
auth = FirebaseAuth.getInstance()
34-
val signInIntent = mGoogleSignInClient.signInIntent
32+
val signInIntent = googleSignInClient.signInIntent
3533
startActivityForResult(signInIntent, RC_SIGN_IN)
3634
}
3735

@@ -46,16 +44,16 @@ class MainActivity : AppCompatActivity() {
4644
try {
4745
// Google Sign In was successful, authenticate with Firebase
4846
val account = task.getResult(ApiException::class.java)!!
49-
Log.d(tag, "firebaseAuthWithGoogle:" + account.id)
47+
Log.d(TAG, "firebaseAuthWithGoogle:" + account.id)
5048
firebaseAuthWithGoogle(account.idToken!!)
5149
setContentView(R.layout.activity_main)
5250
setupNavigationBar()
5351
} catch (e: ApiException) {
5452
// Google Sign In failed
55-
Log.w(tag, "Google sign in failed", e)
53+
Log.w(TAG, "Google sign in failed", e)
5654
}
5755
} else {
58-
Log.w(tag, "Google sign in unsuccessful")
56+
Log.w(TAG, "Google sign in unsuccessful")
5957
}
6058

6159
}
@@ -69,12 +67,12 @@ class MainActivity : AppCompatActivity() {
6967
.addOnCompleteListener(this) { task ->
7068
if (task.isSuccessful) {
7169
// Firebase Sign in success, update UI with the signed-in user's information
72-
Log.d(firebaseTag, "signInWithCredential:success")
70+
Log.d(FIREBASE_TAG, "signInWithCredential:success")
7371
val user = auth.currentUser
74-
Log.d(firebaseTag, "signed-in user's Email:" + user!!.email)
72+
Log.d(FIREBASE_TAG, "signed-in user's Email:" + user!!.email)
7573
} else {
7674
// If sign in fails, log a message to the user.
77-
Log.w(firebaseTag, "signInWithCredential:failure", task.exception)
75+
Log.w(FIREBASE_TAG, "signInWithCredential:failure", task.exception)
7876
}
7977
}
8078
}
@@ -152,6 +150,8 @@ class MainActivity : AppCompatActivity() {
152150

153151
companion object {
154152
private const val RC_SIGN_IN = 0
153+
private const val TAG = "MainActivity-Login"
154+
private const val FIREBASE_TAG = "MainAct-firebase-Login"
155155
}
156156

157157

android/canonical/app/src/main/java/com/google/samples/quickstart/canonical/MeFragment.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import com.google.firebase.auth.FirebaseAuth
1414

1515
private const val ARG_PARAM1 = "param1"
1616
private const val ARG_PARAM2 = "param2"
17-
private const val meTag = "MeFragment"
17+
1818

1919
/**
2020
* A simple [Fragment] subclass.
@@ -50,7 +50,7 @@ class MeFragment : Fragment() {
5050
logoutButton.setOnClickListener {
5151
// Sign out both Google account and Firebase
5252
FirebaseAuth.getInstance().signOut()
53-
(activity as MainActivity).mGoogleSignInClient.signOut().addOnCompleteListener {
53+
(activity as MainActivity).googleSignInClient.signOut().addOnCompleteListener {
5454
val intent = Intent(context, MainActivity::class.java)
5555
startActivity(intent)
5656
}
@@ -62,10 +62,10 @@ class MeFragment : Fragment() {
6262
super.onStart()
6363
val account = GoogleSignIn.getLastSignedInAccount(this.context)
6464
account?.let {
65-
Log.i(meTag, "Already login")
65+
Log.i(ME_TAG, "Already login")
6666
view?.findViewById<TextView>(R.id.textView)?.text = account.displayName
6767
} ?.run {
68-
Log.i(meTag, "No login")
68+
Log.i(ME_TAG, "No login")
6969
}
7070
}
7171

@@ -79,6 +79,9 @@ class MeFragment : Fragment() {
7979
* @param param2 Parameter 2.
8080
* @return A new instance of fragment MeFragment.
8181
*/
82+
83+
private const val ME_TAG = "MeFragment"
84+
8285
// TODO: Rename and change types and number of parameters
8386
@JvmStatic
8487
fun newInstance(param1: String, param2: String) =

android/canonical/app/src/main/java/com/google/samples/quickstart/canonical/RunFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import androidx.fragment.app.Fragment
66
import android.view.LayoutInflater
77
import android.view.View
88
import android.view.ViewGroup
9-
import android.widget.Button
109
import android.widget.Chronometer
1110
import androidx.databinding.DataBindingUtil
1211
import androidx.lifecycle.ViewModelProviders
@@ -51,6 +50,8 @@ class RunFragment : Fragment() {
5150
param2 = it.getString(ARG_PARAM2)
5251
}
5352

53+
// stopwatchVM = StopwatchViewModel()
54+
5455
stopwatchVM = activity?.run {
5556
ViewModelProviders.of(this)[StopwatchViewModel::class.java]
5657
} ?: throw Exception("Null Activity")

0 commit comments

Comments
 (0)