From bdb0fc8e24a76888e7352bb903d0544dd1442b6f Mon Sep 17 00:00:00 2001 From: Tirtharaj Sinha Date: Tue, 23 Nov 2021 18:55:33 +0530 Subject: [PATCH] updated app --- .../com/example/todo_app/LoginActivity.java | 16 +++- .../com/example/todo_app/fourthFragment.java | 9 +- app/src/main/res/layout/fragment_fourth.xml | 82 +++++++++++++------ 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/example/todo_app/LoginActivity.java b/app/src/main/java/com/example/todo_app/LoginActivity.java index 0d28173..701f03e 100644 --- a/app/src/main/java/com/example/todo_app/LoginActivity.java +++ b/app/src/main/java/com/example/todo_app/LoginActivity.java @@ -27,11 +27,11 @@ public class LoginActivity extends AppCompatActivity { GoogleSignInClient mGoogleSignInClient; Button signInButton; + private long pressedTime; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loginactivity); - GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); @@ -63,6 +63,7 @@ public void updateUI(GoogleSignInAccount account){ String personId = account.getId(); Uri personPhoto = account.getPhotoUrl(); final Intent i=new Intent(LoginActivity.this,MainActivity.class); + finish(); startActivity(i); @@ -99,4 +100,17 @@ private void handleSignInResult(Task completedTask) { Log.d("GOOGLE ERROR",e.getMessage()); } } + + @Override + public void onBackPressed() { + + if (pressedTime + 2000 > System.currentTimeMillis()) { + super.onBackPressed(); + finish(); + } else { + Toast.makeText(getBaseContext(), "Press back again to exit", Toast.LENGTH_SHORT).show(); + + } + pressedTime = System.currentTimeMillis(); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/todo_app/fourthFragment.java b/app/src/main/java/com/example/todo_app/fourthFragment.java index e2e8fee..3a54dc2 100644 --- a/app/src/main/java/com/example/todo_app/fourthFragment.java +++ b/app/src/main/java/com/example/todo_app/fourthFragment.java @@ -40,6 +40,8 @@ public class fourthFragment extends Fragment { Context thiscontext; View view; TextView textView3; + TextView textView4; + TextView textView5; CircularImageView usrdp; public fourthFragment(){ @@ -87,8 +89,12 @@ public void updateUI(GoogleSignInAccount account){ String personId = account.getId(); Uri personPhoto = account.getPhotoUrl(); textView3=view.findViewById(R.id.textView3); + textView4=view.findViewById(R.id.textView4); + textView5=view.findViewById(R.id.textView5); usrdp =view.findViewById(R.id.UserImage); - textView3.setText("hi, "+personGivenName); + textView3.setText(personName); + textView4.setText("@"+personEmail); + textView5.setText("hi, "+personGivenName); textView3.setTextSize(20); Picasso.get().load(personPhoto).into(usrdp); System.out.println(personPhoto); @@ -106,6 +112,7 @@ public void updateUI(GoogleSignInAccount account){ public void redirectAuthPage(){ final Intent i=new Intent(thiscontext,LoginActivity.class); + getActivity().finish(); startActivity(i); } diff --git a/app/src/main/res/layout/fragment_fourth.xml b/app/src/main/res/layout/fragment_fourth.xml index 9bd2c25..f318807 100644 --- a/app/src/main/res/layout/fragment_fourth.xml +++ b/app/src/main/res/layout/fragment_fourth.xml @@ -18,19 +18,17 @@