Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
magonyfur committed Dec 22, 2022
0 parents commit 9375fcb
Show file tree
Hide file tree
Showing 112 changed files with 5,568 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Messenger #

If you want a APK then create an issue, i'll send the link..
<br><b>ChatApp is a real time one to one chat application with Push Notifications made using Firebase...</b>

Add yours google-services.json
<br><b> Change Authorization:key with your key from firebase project</b>

<br>Implementation Guide
<br>1 - Project
<br>1 - Open the Project in your android studio;
<br>2 - *IMPORTANT* Change the Package Name. (https://stackoverflow.com/questions/16804093/android-studio-rename-package)

<br>2 - Firebase Panel
<br>- Create Firebase Project (https://console.firebase.google.com/);
<br>- Import the file google-service.json into your project
<br>- Connect to firebase console authentication and database from your IDE
<br>- in firebase Storage Rules, change value of "allow read, write:" from "if request.auth != null" to "if true;"
<br>- For sending notification, paste your Firebase project key into your project APIService.java
<br>- When you change database settings, you likely will need to uninstall and reinstall apps to avoid app crashes due to app caches.

Check out the design...
# Welcome, Login, Signup, Forgot Password
<img src="https://user-images.githubusercontent.com/26492582/67112482-f7031780-f1f4-11e9-8264-4245187fbc8d.png" width="200" height="400"/> <img src="https://user-images.githubusercontent.com/26492582/67112477-f7031780-f1f4-11e9-843e-43ef987ea1df.png" width="200" height="400"/> <img src="https://user-images.githubusercontent.com/26492582/67112478-f7031780-f1f4-11e9-8beb-1daa94300ccb.png" width="200" height="400"/> <img src="https://user-images.githubusercontent.com/26492582/67112474-f5d1ea80-f1f4-11e9-83ab-f89e4d55967e.png" width="200" height="400"/>

# Chats, Users, Profile Screens
<img src="https://user-images.githubusercontent.com/26492582/67112193-45fc7d00-f1f4-11e9-8350-2c42c320f73b.png" width="250" height="500"/> <img src="https://user-images.githubusercontent.com/26492582/67112192-45fc7d00-f1f4-11e9-9dc6-f7a92db849da.png" width="250" height="500"/> <img src="https://user-images.githubusercontent.com/26492582/67112191-45fc7d00-f1f4-11e9-83a7-06da1a9b2457.png" width="250" height="500"/>

# Chat Screen, Friend Profile, Logout Menu
<img src="https://user-images.githubusercontent.com/26492582/67112187-4432b980-f1f4-11e9-94da-910e9e749702.png" width="250" height="500"/> <img src="https://user-images.githubusercontent.com/26492582/67112181-439a2300-f1f4-11e9-9125-6fa64426e583.png" width="250" height="500"/> <img src="https://user-images.githubusercontent.com/26492582/67112180-43018c80-f1f4-11e9-82c2-7c299e6d9cc1.png" width="250" height="500"/>




1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
50 changes: 50 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.saharsh.chatapp"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'

//libraries we need for now
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
//add this
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
//add this library and this
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'

//add these libraries
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.firebase:firebase-messaging:17.3.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.saharsh.chatapp;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.koddev.chatapp", appContext.getPackageName());
}
}
59 changes: 59 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.saharsh.chatapp">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ViewProfileActivity"></activity>
<activity
android:name=".StartActivity"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RegisterActivity"
android:parentActivityName=".StartActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".MainActivity" />
<activity
android:name=".LoginActivity"
android:parentActivityName=".StartActivity"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".MessageActivity" />
<activity
android:name=".ResetPasswordActivity"
android:parentActivityName=".LoginActivity"
android:windowSoftInputMode="stateAlwaysHidden" />

<service
android:name=".Notifications.MyFirebaseIdService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name=".Notifications.MyFirebaseMessaging"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.INTERNET" />

</manifest>
Binary file added app/src/main/assets/fonts/myriad.ttf
Binary file not shown.
Binary file added app/src/main/assets/fonts/myriadregular.ttf
Binary file not shown.
Binary file added app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions app/src/main/java/com/saharsh/chatapp/Adapter/MessageAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.saharsh.chatapp.Adapter;

import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.saharsh.chatapp.Model.Chat;
import com.saharsh.chatapp.R;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.ViewHolder> {

public static final int MSG_TYPE_LEFT = 0;
public static final int MSG_TYPE_RIGHT = 1;
Typeface MR,MRR;


private Context mContext;
private List<Chat> mChat;
private String imageurl;

FirebaseUser fuser;

public MessageAdapter(Context mContext, List<Chat> mChat, String imageurl){
this.mChat = mChat;
this.mContext = mContext;
this.imageurl = imageurl;

MRR = Typeface.createFromAsset(mContext.getAssets(), "fonts/myriadregular.ttf");
MR = Typeface.createFromAsset(mContext.getAssets(), "fonts/myriad.ttf");

}

@NonNull
@Override
public MessageAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == MSG_TYPE_RIGHT) {
View view = LayoutInflater.from(mContext).inflate(R.layout.chat_item_right, parent, false);
return new MessageAdapter.ViewHolder(view);
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.chat_item_left, parent, false);
return new MessageAdapter.ViewHolder(view);
}
}

@Override
public void onBindViewHolder(@NonNull MessageAdapter.ViewHolder holder, int position) {

Chat chat = mChat.get(position);
holder.show_message.setTypeface(MRR);
holder.txt_seen.setTypeface(MRR);

holder.show_message.setText(chat.getMessage());
if(chat.getTime()!=null && !chat.getTime().trim().equals("")) {
holder.time_tv.setText(holder.convertTime(chat.getTime()));
}

if (imageurl.equals("default")){
holder.profile_image.setImageResource(R.drawable.profile_img);
} else {
Glide.with(mContext).load(imageurl).into(holder.profile_image);
}

if (position == mChat.size()-1){
if (chat.isIsseen()){
holder.txt_seen.setText("Seen");
} else {
holder.txt_seen.setText("Delivered");
}
} else {
holder.txt_seen.setVisibility(View.GONE);
}

}

@Override
public int getItemCount() {
return mChat.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{

public TextView show_message;
public ImageView profile_image;
public TextView txt_seen;
public TextView time_tv;
public ViewHolder(View itemView) {
super(itemView);

show_message = itemView.findViewById(R.id.show_message);
profile_image = itemView.findViewById(R.id.profile_image);
txt_seen = itemView.findViewById(R.id.txt_seen);
time_tv = itemView.findViewById(R.id.time_tv);
}

public String convertTime(String time){
SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
String dateString = formatter.format(new Date(Long.parseLong(time)));
return dateString;
}
}

@Override
public int getItemViewType(int position) {
fuser = FirebaseAuth.getInstance().getCurrentUser();
if (mChat.get(position).getSender().equals(fuser.getUid())){
return MSG_TYPE_RIGHT;
} else {
return MSG_TYPE_LEFT;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.saharsh.chatapp.Adapter;

import android.view.View;

public interface OnItemClick {
public void onItemCLick(String uid, View view);
}
Loading

0 comments on commit 9375fcb

Please sign in to comment.