diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 526b4c2..a0de2a1 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -7,13 +7,13 @@
+
-
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7e39029..2f74ce1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,6 +3,17 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 9e5d6e4..f9da181 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,7 +4,7 @@ plugins {
}
android {
- compileSdk 31
+ compileSdk 33
buildFeatures {
viewBinding true
@@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId "com.example.social_media_chat_app"
minSdk 21
- targetSdk 31
+ targetSdk 33
versionCode 1
versionName "1.0"
@@ -34,16 +34,24 @@ android {
dependencies {
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation 'com.google.android.material:material:1.4.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
- implementation 'com.google.firebase:firebase-auth:21.0.1'
- implementation 'com.google.firebase:firebase-database:20.0.2'
- implementation 'com.google.firebase:firebase-storage:20.0.0'
- implementation 'com.google.firebase:firebase-config:21.0.1'
- testImplementation 'junit:junit:4.+'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+ implementation 'com.google.android.material:material:1.8.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ implementation 'com.google.firebase:firebase-auth:21.1.0'
+ implementation 'com.google.firebase:firebase-database:20.1.0'
+ implementation 'com.google.firebase:firebase-storage:20.1.0'
+ implementation 'com.google.firebase:firebase-config:21.2.1'
+ implementation 'com.google.firebase:firebase-firestore:24.4.3'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+
+ //Firebase
+ implementation platform('com.google.firebase:firebase-bom:30.1.0')
+ implementation 'com.google.firebase:firebase-auth'
+ implementation 'com.google.android.gms:play-services-auth:20.4.1'
+ implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
+ implementation platform('com.google.firebase:firebase-bom:30.1.0')
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'de.hdodenhof:circleimageview:3.1.0'
diff --git a/app/src/google-services.json b/app/src/google-services.json
new file mode 100644
index 0000000..7f6fed2
--- /dev/null
+++ b/app/src/google-services.json
@@ -0,0 +1,77 @@
+{
+ "project_info": {
+ "project_number": "496050149411",
+ "firebase_url": "https://habagolfers-default-rtdb.firebaseio.com",
+ "project_id": "habagolfers",
+ "storage_bucket": "habagolfers.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:496050149411:android:22c4a6010b1ec850123996",
+ "android_client_info": {
+ "package_name": "com.example.social_media_chat_app"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "496050149411-i9opdbd8h8udrjtao8mlcr70u025kccr.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyBI6sANQvgxt7ZrirTSY5kqzA9I55SuPC4"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "496050149411-i9opdbd8h8udrjtao8mlcr70u025kccr.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ },
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:496050149411:android:0204a8f5aded494c123996",
+ "android_client_info": {
+ "package_name": "com.haba.habagolfers"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "496050149411-thhfh3lvvt0j131uks50unc9qt96s54g.apps.googleusercontent.com",
+ "client_type": 1,
+ "android_info": {
+ "package_name": "com.haba.habagolfers",
+ "certificate_hash": "0ed62de79c3254e82457c44710a22b3d6702df86"
+ }
+ },
+ {
+ "client_id": "496050149411-i9opdbd8h8udrjtao8mlcr70u025kccr.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyBI6sANQvgxt7ZrirTSY5kqzA9I55SuPC4"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "496050149411-i9opdbd8h8udrjtao8mlcr70u025kccr.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/social_media_chat_app/Activity/HomeActivity.java b/app/src/main/java/com/example/social_media_chat_app/Activity/HomeActivity.java
index 1e3ee32..8fc9333 100644
--- a/app/src/main/java/com/example/social_media_chat_app/Activity/HomeActivity.java
+++ b/app/src/main/java/com/example/social_media_chat_app/Activity/HomeActivity.java
@@ -29,6 +29,7 @@
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
+import java.util.Objects;
import de.hdodenhof.circleimageview.CircleImageView;
@@ -60,12 +61,10 @@ public void onClick(View v) {
}
});
// getSupportActionBar().hide();
- if (Build.VERSION.SDK_INT >= 21) {
- Window window = this.getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- window.setStatusBarColor(this.getResources().getColor(R.color.primary_purple));
- }
+ Window window = this.getWindow();
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.setStatusBarColor(this.getResources().getColor(R.color.primary_purple));
DatabaseReference reference=database.getReference().child("user");
reference.addValueEventListener(new ValueEventListener() {
@@ -73,6 +72,7 @@ public void onClick(View v) {
public void onDataChange(@NonNull DataSnapshot snapshot) {
for(DataSnapshot dataSnapshot:snapshot.getChildren()){
Users users= dataSnapshot.getValue(Users.class);
+ assert users != null;
if(!users.getUid().equals(FirebaseAuth.getInstance().getUid()))
usersArrayList.add(users);
@@ -133,15 +133,16 @@ public void onClick(View v) {
}
});*/
- DatabaseReference reference1=database.getReference().child("user").child(auth.getUid());
+
+ DatabaseReference reference1=database.getReference().child("user").child(Objects.requireNonNull(auth.getUid()));
reference1.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
- String email=snapshot.child("email").getValue().toString();
- String name=snapshot.child("name").getValue().toString();
- String status=snapshot.child("status").getValue().toString();
- String image=snapshot.child("imageUri").getValue().toString();
+ String email= Objects.requireNonNull(snapshot.child("email").getValue()).toString();
+ String name= Objects.requireNonNull(snapshot.child("name").getValue()).toString();
+ String status= Objects.requireNonNull(snapshot.child("status").getValue()).toString();
+ String image= Objects.requireNonNull(snapshot.child("imageUri").getValue()).toString();
Picasso.get().load(image).placeholder(R.drawable.placeholder_profile_image).into(img_setting);
diff --git a/app/src/main/java/com/example/social_media_chat_app/Activity/MainActivity.java b/app/src/main/java/com/example/social_media_chat_app/Activity/MainActivity.java
index d40ef6c..26c73aa 100644
--- a/app/src/main/java/com/example/social_media_chat_app/Activity/MainActivity.java
+++ b/app/src/main/java/com/example/social_media_chat_app/Activity/MainActivity.java
@@ -1,7 +1,6 @@
package com.example.social_media_chat_app.Activity;
import android.content.Intent;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
@@ -10,31 +9,47 @@
import androidx.appcompat.app.AppCompatActivity;
import com.example.social_media_chat_app.R;
+import com.google.firebase.auth.FirebaseAuth;
+import com.google.firebase.auth.FirebaseUser;
public class MainActivity extends AppCompatActivity {
+ FirebaseUser currentUser;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// getSupportActionBar().hide();
- if (Build.VERSION.SDK_INT >= 21) {
- Window window = this.getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- window.setStatusBarColor(this.getResources().getColor(R.color.white));
- }
-
-
- new Handler().postDelayed(new Runnable() {
+ Window window = this.getWindow();
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.setStatusBarColor(this.getResources().getColor(R.color.white));
+
+ currentUser = FirebaseAuth.getInstance().getCurrentUser();
+
+
+ Handler handler = new Handler();
+ handler.postDelayed(() -> {
+ FirebaseUser currentUser;
+ currentUser = FirebaseAuth.getInstance().getCurrentUser();
+ if(currentUser != null){
+ toHomeDashboard();
+ }else {
+ toSignUpActivity();
+ }
+ }, 3000);
+ }
+ private void toHomeDashboard() {
+ Intent intent = new Intent(MainActivity.this, HomeActivity.class);
+ startActivity(intent);
+ finish();
+ }
- @Override
- public void run() {
- Intent i = new Intent(MainActivity.this, HomeActivity.class);
- startActivity(i);
- finish();
- }
- }, 2000);
+ private void toSignUpActivity() {
+ Intent intent = new Intent(MainActivity.this, RegistrationActivity.class);
+ startActivity(intent);
+ finish();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/social_media_chat_app/Activity/RegistrationActivity.java b/app/src/main/java/com/example/social_media_chat_app/Activity/RegistrationActivity.java
index f04e0a3..0bc3b88 100644
--- a/app/src/main/java/com/example/social_media_chat_app/Activity/RegistrationActivity.java
+++ b/app/src/main/java/com/example/social_media_chat_app/Activity/RegistrationActivity.java
@@ -30,6 +30,8 @@
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
+import java.util.Objects;
+
import de.hdodenhof.circleimageview.CircleImageView;
public class RegistrationActivity extends AppCompatActivity {
@@ -65,12 +67,10 @@ protected void onCreate(Bundle savedInstanceState) {
btn_SignUp=findViewById(R.id.btn_SignUp);
// getSupportActionBar().hide();
- if (Build.VERSION.SDK_INT >= 21) {
- Window window = this.getWindow();
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- window.setStatusBarColor(this.getResources().getColor(R.color.primary_purple));
- }
+ Window window = this.getWindow();
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.setStatusBarColor(this.getResources().getColor(R.color.primary_purple));
btn_SignUp.setOnClickListener(new View.OnClickListener() {
@Override
@@ -101,7 +101,7 @@ public void onClick(View v) {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()){
- DatabaseReference reference= database.getReference().child("user").child(auth.getUid());
+ DatabaseReference reference= database.getReference().child("user").child(Objects.requireNonNull(auth.getUid()));
StorageReference storageReference=storage.getReference().child("upload").child(auth.getUid());
if(imageUri!=null){
storageReference.putFile(imageUri).addOnCompleteListener(new OnCompleteListener() {
@@ -112,15 +112,16 @@ public void onComplete(@NonNull Task task) {
@Override
public void onSuccess(Uri uri) {
imageURI=uri.toString();
- Users users=new Users(auth.getUid(), name, email, imageURI, status);
+ Users users = new Users(auth.getUid(), name, email, imageURI, status);
reference.setValue(users).addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()){
progressDialog.dismiss();
- startActivity(new Intent(RegistrationActivity.this, HomeActivity.class));
+ startActivity(new Intent(RegistrationActivity.this, LoginActivity.class));
}else{
- Toast.makeText(RegistrationActivity.this, "Error in creating a new user", Toast.LENGTH_SHORT).show();
+ Toast.makeText(RegistrationActivity.this, "Error in creating a new user first test", Toast.LENGTH_SHORT).show();
+ progressDialog.dismiss();
}
}
diff --git a/build.gradle b/build.gradle
index 788c425..4997fa3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,8 +5,8 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath "com.android.tools.build:gradle:7.0.2"
- classpath 'com.google.gms:google-services:4.3.10'
+ classpath 'com.android.tools.build:gradle:7.2.2'
+ classpath 'com.google.gms:google-services:4.3.15'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle.properties b/gradle.properties
index 52f5917..4f1afa0 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -16,4 +16,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
-android.enableJetifier=true
\ No newline at end of file
+android.enableJetifier=true
+org.gradle.unsafe.configuration-cache=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0e66fb3..b1e6856 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Wed Nov 17 10:44:43 IST 2021
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME