Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit 1e59071

Browse files
author
Honey Sharma
authored
Merge pull request #3 from honeycoder96/development
Merging Development to master
2 parents cd37285 + 5bb517a commit 1e59071

18 files changed

+225
-107
lines changed

.idea/caches/build_file_checksums.ser

537 Bytes
Binary file not shown.

.idea/codeStyles/Project.xml

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+6-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
4+
compileSdkVersion 28
55
defaultConfig {
66
applicationId "tech.honeysharma.techbmechat"
77
minSdkVersion 15
8-
targetSdkVersion 25
8+
targetSdkVersion 28
99
versionCode 1
1010
versionName "1.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,26 +20,28 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:25.4.0'
23+
//noinspection GradleCompatible
24+
implementation 'com.android.support:appcompat-v7:28.0.0'
2425
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
2526
testImplementation 'junit:junit:4.12'
2627
androidTestImplementation 'com.android.support.test:runner:1.0.1'
2728
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
2829

2930

30-
compile 'com.android.support:design:25.4.0'
31-
compile 'com.google.firebase:firebase-auth:10.2.1'
32-
compile 'com.android.support:support-v4:25.4.0'
31+
compile 'com.android.support:design:28.0.0'
32+
compile 'com.google.firebase:firebase-auth:16.0.4'
33+
implementation 'com.google.android.gms:play-services-auth:16.0.1'
34+
compile 'com.android.support:support-v4:28.0.0'
3335
compile 'de.hdodenhof:circleimageview:2.1.0'
34-
compile 'com.google.firebase:firebase-database:10.2.1'
36+
compile 'com.google.firebase:firebase-database:16.0.3'
3537
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
36-
compile 'com.google.firebase:firebase-storage:10.2.1'
38+
compile 'com.google.firebase:firebase-storage:16.0.3'
3739
compile 'com.firebaseui:firebase-ui-database:1.2.0'
3840
compile 'id.zelory:compressor:2.0.0'
3941
compile 'com.squareup.picasso:picasso:2.5.2'
4042
compile 'com.squareup.okhttp:okhttp:2.5.0'
41-
compile 'com.google.firebase:firebase-messaging:10.2.1'
42-
compile 'com.android.support:cardview-v7:25.4.0'
43+
compile 'com.google.firebase:firebase-messaging:17.3.3'
44+
compile 'com.android.support:cardview-v7:28.0.0'
4345
}
4446

4547
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="tech.honeysharma.techbmechat">
45

6+
7+
58
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
69
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
710

@@ -40,7 +43,8 @@
4043
<activity
4144
android:name=".Chat.ChatActivity"
4245
android:parentActivityName=".Account.MainActivity" />
43-
<activity android:name=".Blog.BlogActivity" />
46+
<activity android:name=".Blog.BlogActivity"
47+
android:parentActivityName=".Account.MainActivity"/>
4448
<activity android:name=".Blog.PostActivity"></activity>
4549
</application>
4650

app/src/main/java/tech/honeysharma/techbmechat/Account/LoginActivity.java

+68-21
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import android.os.Bundle;
99
import android.support.v7.widget.Toolbar;
1010
import android.text.TextUtils;
11+
import android.util.Log;
1112
import android.view.View;
1213
import android.widget.Button;
1314
import android.widget.Toast;
1415

1516
import com.google.android.gms.tasks.OnCompleteListener;
17+
import com.google.android.gms.tasks.OnFailureListener;
1618
import com.google.android.gms.tasks.OnSuccessListener;
1719
import com.google.android.gms.tasks.Task;
1820
import com.google.firebase.auth.AuthResult;
@@ -21,6 +23,8 @@
2123
import com.google.firebase.database.FirebaseDatabase;
2224
import com.google.firebase.iid.FirebaseInstanceId;
2325

26+
import java.util.HashMap;
27+
2428
import tech.honeysharma.techbmechat.R;
2529

2630

@@ -94,41 +98,84 @@ public void onClick(View view) {
9498
private void loginUser(String email, String password) {
9599

96100

97-
mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
98-
@Override
99-
public void onComplete(@NonNull Task<AuthResult> task) {
101+
mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
102+
@Override
103+
public void onComplete(@NonNull Task<AuthResult> task) {
104+
105+
if(task.isSuccessful()){
106+
107+
mLoginProgress.dismiss();
108+
109+
String current_user_id = mAuth.getCurrentUser().getUid();
110+
String deviceToken = FirebaseInstanceId.getInstance().getToken();
111+
112+
if (mAuth.getCurrentUser().isEmailVerified()) {
113+
114+
115+
// mDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(user.getUid());
116+
117+
String device_token = FirebaseInstanceId.getInstance().getToken();
118+
119+
HashMap<String, String> userMap = new HashMap<>();
120+
userMap.put("name", getSharedPreferences("APP_PREF", MODE_PRIVATE).getString("name", null));
121+
userMap.put("status", "Hi there I'm using TechnoJam Chat App.");
122+
userMap.put("image", "default");
123+
userMap.put("thumb_image", "default");
124+
userMap.put("device_token", device_token);
100125

101-
if(task.isSuccessful()){
126+
Log.e("A", "onComplete: ");
102127

103-
mLoginProgress.dismiss();
128+
mUserDatabase.child(mAuth.getCurrentUser().getUid()).setValue(userMap).addOnCompleteListener(new OnCompleteListener<Void>() {
129+
@Override
130+
public void onComplete(@NonNull Task<Void> task) {
104131

105-
String current_user_id = mAuth.getCurrentUser().getUid();
106-
String deviceToken = FirebaseInstanceId.getInstance().getToken();
132+
Log.e("B", "onComplete: ");
133+
if(task.isSuccessful()){
107134

108-
mUserDatabase.child(current_user_id).child("device_token").setValue(deviceToken).addOnSuccessListener(new OnSuccessListener<Void>() {
109-
@Override
110-
public void onSuccess(Void aVoid) {
135+
Log.e("C", "onComplete: is Successfull");
136+
Log.e("RegisterActivity", "onComplete: Data added to db");
137+
Intent mainIntent = new Intent(LoginActivity.this, MainActivity.class);
138+
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
139+
startActivity(mainIntent);
140+
finish();
141+
/** Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
142+
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
143+
startActivity(mainIntent);
144+
finish(); */
145+
}
146+
}
147+
}).addOnFailureListener(new OnFailureListener() {
148+
@Override
149+
public void onFailure(@NonNull Exception e) {
150+
Log.e("D", "onFailure: " + e.getMessage());
151+
}
152+
});
111153

112-
Intent mainIntent = new Intent(LoginActivity.this, MainActivity.class);
113-
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
114-
startActivity(mainIntent);
115-
finish();
116154

117155

156+
} else {
157+
158+
Toast.makeText(LoginActivity.this, "Account not verified yet! Unable to Login!", Toast.LENGTH_SHORT).show();
118159
}
119-
});
120-
} else {
121160

122-
mLoginProgress.hide();
123161

124-
String task_result = task.getException().getMessage().toString();
162+
} else {
163+
164+
mLoginProgress.hide();
165+
166+
String task_result = task.getException().getMessage().toString();
125167

126-
Toast.makeText(LoginActivity.this, "Error : " + task_result, Toast.LENGTH_LONG).show();
168+
Toast.makeText(LoginActivity.this, "Error : " + task_result, Toast.LENGTH_LONG).show();
169+
170+
}
127171

128172
}
173+
});
174+
175+
176+
177+
129178

130-
}
131-
});
132179

133180

134181
}

0 commit comments

Comments
 (0)