Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commmit Updates #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 20 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

android {
compileSdk 31
compileSdk 33

buildFeatures {
viewBinding true
Expand All @@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId "com.example.social_media_chat_app"
minSdk 21
targetSdk 31
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -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'
Expand Down
77 changes: 77 additions & 0 deletions app/src/google-services.json
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.Objects;

import de.hdodenhof.circleimageview.CircleImageView;

Expand Down Expand Up @@ -60,19 +61,18 @@ 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() {
@Override
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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -101,7 +101,7 @@ public void onClick(View v) {
@Override
public void onComplete(@NonNull Task<AuthResult> 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<UploadTask.TaskSnapshot>() {
Expand All @@ -112,15 +112,16 @@ public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> 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<Void>() {
@Override
public void onComplete(@NonNull Task<Void> 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();
}

}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
android.enableJetifier=true
org.gradle.unsafe.configuration-cache=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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