55import android .os .Bundle ;
66import android .util .Log ;
77import android .view .View ;
8+ import android .view .WindowManager ;
89import android .widget .Button ;
910import android .widget .TextView ;
1011import android .widget .Toast ;
2627import com .google .firebase .auth .FirebaseUser ;
2728import com .google .firebase .auth .GoogleAuthProvider ;
2829
29-
30- /*import com.google.android.material.snackbar.Snackbar;
31- import com.google.firebase.quickstart.auth.R;
32- import com.google.firebase.quickstart.auth.databinding.ActivityGoogleBinding;*/
33-
34-
35-
36-
37-
38- /**
39- * Demonstrate Firebase Authentication using a Google ID Token.
40- */
4130public class GoogleSignInActivity extends AppCompatActivity implements
4231 View .OnClickListener {
4332
4433 private static final String TAG = "GoogleActivity" ;
4534 private static final int RC_SIGN_IN = 9001 ;
4635
47- // [START declare_auth]
4836 private FirebaseAuth mAuth ;
49- // [END declare_auth]
37+
5038
5139 private GoogleSignInClient mGoogleSignInClient ;
5240 private TextView mStatusTextView ;
@@ -68,6 +56,11 @@ protected void onCreate(Bundle savedInstanceState) {
6856
6957 setContentView (R .layout .activity_google_sign_in );
7058
59+
60+ getWindow ().setFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN ,WindowManager .LayoutParams .FLAG_FULLSCREEN );
61+
62+ getSupportFragmentManager ().beginTransaction ().replace (R .id .wrapper ,new recfragment ()).commit ();
63+
7164 mStatusTextView = (TextView ) findViewById (R .id .status );
7265 mDetailTextView = (TextView ) findViewById (R .id .detail );
7366
@@ -107,69 +100,50 @@ public void onClick(View v) {
107100 });
108101
109102
110- /*mBinding = ActivityGoogleBinding.inflate(getLayoutInflater());
111- setContentView(mBinding.getRoot());
112- setProgressBar(mBinding.progressBar); */
113103
114- // Button listeners
115104 findViewById (R .id .signInButton ).setOnClickListener (this );
116105 findViewById (R .id .signOutButton ).setOnClickListener (this );
117106 findViewById (R .id .disconnectButton ).setOnClickListener (this );
118107
119- // [START config_signin]
120- // Configure Google Sign In
108+
121109 GoogleSignInOptions gso = new GoogleSignInOptions .Builder (GoogleSignInOptions .DEFAULT_SIGN_IN )
122110 .requestIdToken (getString (R .string .default_web_client_id ))
123111 .requestEmail ()
124112 .build ();
125- // [END config_signin]
126113
127114 mGoogleSignInClient = GoogleSignIn .getClient (this , gso );
128115
129- // [START initialize_auth]
130- // Initialize Firebase Auth
131116 mAuth = FirebaseAuth .getInstance ();
132- // [END initialize_auth]
133117 }
134118
135- // [START on_start_check_user]
136119 @ Override
137120 public void onStart () {
138121 super .onStart ();
139- // Check if user is signed in (non-null) and update UI accordingly.
140122 FirebaseUser currentUser = mAuth .getCurrentUser ();
141123 updateUI (currentUser );
142124 }
143- // [END on_start_check_user]
144125
145- // [START onactivityresult]
146126 @ Override
147127 public void onActivityResult (int requestCode , int resultCode , Intent data ) {
148128 super .onActivityResult (requestCode , resultCode , data );
149129
150- // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
151130 if (requestCode == RC_SIGN_IN ) {
152131 Task <GoogleSignInAccount > task = GoogleSignIn .getSignedInAccountFromIntent (data );
153132 try {
154- // Google Sign In was successful, authenticate with Firebase
155133 GoogleSignInAccount account = task .getResult (ApiException .class );
156134 Log .d (TAG , "firebaseAuthWithGoogle:" + account .getId ());
157135 firebaseAuthWithGoogle (account .getIdToken ());
158136 } catch (ApiException e ) {
159- // Google Sign In failed, update UI appropriately
137+
160138 Log .w (TAG , "Google sign in failed" , e );
161- // [START_EXCLUDE]
139+
162140 updateUI (null );
163- // [END_EXCLUDE]
141+
164142 }
165143 }
166144 }
167- // [END onactivityresult]
168145
169- // [START auth_with_google]
170146 private void firebaseAuthWithGoogle (String idToken ) {
171- // [START_EXCLUDE silent];
172- // [END_EXCLUDE]
173147 AuthCredential credential = GoogleAuthProvider .getCredential (idToken , null );
174148 mAuth .signInWithCredential (credential )
175149 .addOnCompleteListener (this , new OnCompleteListener <AuthResult >() {
@@ -187,25 +161,18 @@ public void onComplete(@NonNull Task<AuthResult> task) {
187161 updateUI (null );
188162 }
189163
190- // [START_EXCLUDE]
191- // [END_EXCLUDE]
192164 }
193165 });
194166 }
195- // [END auth_with_google]
196167
197- // [START signin]
198168 private void signIn () {
199169 Intent signInIntent = mGoogleSignInClient .getSignInIntent ();
200170 startActivityForResult (signInIntent , RC_SIGN_IN );
201171 }
202- // [END signin]
203172
204173 private void signOut () {
205- // Firebase sign out
206174 mAuth .signOut ();
207175
208- // Google sign out
209176 mGoogleSignInClient .signOut ().addOnCompleteListener (this ,
210177 new OnCompleteListener <Void >() {
211178 @ Override
@@ -216,7 +183,6 @@ public void onComplete(@NonNull Task<Void> task) {
216183 }
217184
218185 private void revokeAccess () {
219- // Firebase sign out
220186 mAuth .signOut ();
221187
222188 // Google revoke access
@@ -252,6 +218,11 @@ private void updateUI(FirebaseUser user) {
252218 }
253219 }
254220
221+ private void button6Click (){
222+ startActivity (new Intent ("Firebase01.BaseActivity" ));
223+
224+ }
225+
255226 @ Override
256227 public void onClick (View v ) {
257228 int i = v .getId ();
@@ -262,6 +233,12 @@ public void onClick(View v) {
262233 } else if (i == R .id .disconnectButton ) {
263234 revokeAccess ();
264235 }
236+ switch (v .getId ()){
237+ case R .id .button6 :
238+ button6Click ();
239+ break ;
240+ }
241+
265242 }
266243
267244
0 commit comments