Last active
September 15, 2019 07:45
-
-
Save Kapilhk/ba9e323687edc0875e99ac2e7b09bc32 to your computer and use it in GitHub Desktop.
Chat App -Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.harsh.freechat"> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<application | |
android:name=".FreeChat" | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launch" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launch_round" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> | |
<service android:name=".FirebaseMessagingService"> | |
<intent-filter> | |
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | |
</intent-filter> | |
</service> | |
<activity android:name=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
<activity android:name=".StartActivity" /> | |
<activity | |
android:name=".RegisterActivity" | |
android:parentActivityName=".StartActivity" /> | |
<activity android:name=".LoginActivity" | |
android:parentActivityName=".StartActivity"/> | |
<activity android:name=".SettingsActivity" /> | |
<activity | |
android:name=".StatusActivity" | |
android:parentActivityName=".SettingsActivity" /> | |
<activity | |
android:name="com.theartofdev.edmodo.cropper.CropImageActivity" | |
android:theme="@style/Base.Theme.AppCompat" /> | |
<activity | |
android:name=".UsersActivity" | |
android:parentActivityName=".MainActivity" /> | |
<activity android:name=".ProfileActivity"> | |
<intent-filter> | |
<action android:name="com.example.harsh.freechat_TARGET_NOTIFICATION" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter> | |
</activity> | |
<activity android:name=".ChatActivity" | |
android:parentActivityName=".MainActivity"></activity> | |
</application> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <jni.h> | |
#include <string> | |
extern "C" | |
JNIEXPORT jstring | |
JNICALL | |
Java_com_example_harsh_freechat_MainActivity_stringFromJNI( | |
JNIEnv *env, | |
jobject /* this */) { | |
std::string hello = "Hello from C++"; | |
return env->NewStringUTF(hello.c_str()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.support.v4.widget.SwipeRefreshLayout; | |
import android.support.v7.app.ActionBar; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.Toolbar; | |
import android.text.TextUtils; | |
import android.util.Log; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.widget.EditText; | |
import android.widget.ImageButton; | |
import android.widget.TextView; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.ChildEventListener; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.Query; | |
import com.google.firebase.database.ServerValue; | |
import com.google.firebase.database.ValueEventListener; | |
import com.google.firebase.storage.FirebaseStorage; | |
import com.google.firebase.storage.StorageReference; | |
import com.google.firebase.storage.UploadTask; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
public class ChatActivity extends AppCompatActivity { | |
private String mChatUser; | |
private Toolbar mChatToolbar; | |
private DatabaseReference mRootRef; | |
private TextView mTitleView; | |
private TextView mLastSeenView; | |
private CircleImageView mProfileImage; | |
private FirebaseAuth mAuth; | |
private String mCurrentUserId; | |
private ImageButton mChatAddBtn; | |
private ImageButton mChatSendBtn; | |
private EditText mChatMessageView; | |
private RecyclerView mMessageslist; | |
private SwipeRefreshLayout mRefreshLayout; | |
private final List<Messages> messagesList = new ArrayList<>(); | |
private LinearLayoutManager mLinearLayout; | |
private MessageAdapter mAdapter; | |
private static final int TOTAL_ITEMS_TO_LOAD = 10; | |
private int mCurrentPage = 1; | |
private int itemPos = 0; | |
private static final int GALLERY_PICK = 1; | |
// Storage Firebase | |
private StorageReference mImageStorage; | |
private String mLastKey = ""; | |
private String mPrevKey = ""; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_chat); | |
mChatToolbar = findViewById(R.id.chat_app_bar); | |
setSupportActionBar(mChatToolbar); | |
ActionBar actionBar = getSupportActionBar(); | |
actionBar.setDisplayHomeAsUpEnabled(true); | |
actionBar.setDisplayShowCustomEnabled(true); | |
mRootRef = FirebaseDatabase.getInstance().getReference(); | |
mAuth = FirebaseAuth.getInstance(); | |
mCurrentUserId = mAuth.getCurrentUser().getUid(); | |
mChatUser = getIntent().getStringExtra("user_id"); | |
String userName = getIntent().getStringExtra("user_name"); | |
getSupportActionBar().setTitle(userName); | |
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
View action_bar_view = inflater.inflate(R.layout.chat_custom_bar, null); | |
actionBar.setCustomView(action_bar_view); | |
//----------Custom action bar items------------- | |
mTitleView = findViewById(R.id.custom_bar_title); | |
mLastSeenView = findViewById(R.id.custom_bar_seen); | |
mProfileImage = findViewById(R.id.custom_bar_image); | |
mChatAddBtn = findViewById(R.id.chat_add_btn); | |
mChatSendBtn = findViewById(R.id.chat_send_btn); | |
mChatMessageView = findViewById(R.id.chat_message_view); | |
mAdapter = new MessageAdapter(messagesList); | |
mMessageslist = findViewById(R.id.messages_list); | |
mRefreshLayout = findViewById(R.id.message_swipe_layout); | |
mLinearLayout = new LinearLayoutManager(this); | |
mMessageslist.setHasFixedSize(true); | |
mMessageslist.setLayoutManager(mLinearLayout); | |
mMessageslist.setAdapter(mAdapter); | |
//--------IMAGE STORAGE------------- | |
mImageStorage = FirebaseStorage.getInstance().getReference(); | |
mRootRef.child("Chat").child(mCurrentUserId).child(mChatUser).child("seen").setValue(true); | |
loadMessages(); | |
mTitleView.setText(userName); | |
mRootRef.child("Users").child(mChatUser).addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
String online = dataSnapshot.child("online").getValue().toString(); | |
String image = dataSnapshot.child("image").getValue().toString(); | |
if (online.equals("true")) { | |
mLastSeenView.setText("Online"); | |
} else { | |
GetTimeAgo getTimeAgo = new GetTimeAgo(); | |
long lastTime = Long.parseLong(online); | |
String lastSeenTime = getTimeAgo.getTimeAgo(lastTime, getApplicationContext()); | |
mLastSeenView.setText(lastSeenTime); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
mRootRef.child("Chat").child(mCurrentUserId).addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if (!dataSnapshot.hasChild(mChatUser)) { | |
Map chatAddMap = new HashMap(); | |
chatAddMap.put("seen", false); | |
chatAddMap.put("timestamp", ServerValue.TIMESTAMP); | |
Map chatUserMap = new HashMap(); | |
chatUserMap.put("Chat/" + mCurrentUserId + "/" + mChatUser, chatAddMap); | |
chatUserMap.put("Chat/" + mChatUser + "/" + mCurrentUserId, chatAddMap); | |
mRootRef.updateChildren(chatUserMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if (databaseError != null) { | |
Log.d("Chat Log", databaseError.getMessage().toString()); | |
} | |
} | |
}); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
mChatSendBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
sendMessage(); | |
} | |
}); | |
mChatAddBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Intent galleryIntent = new Intent(); | |
galleryIntent.setType("image/*"); | |
galleryIntent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult(Intent.createChooser(galleryIntent, "SELECT IMAGE"), GALLERY_PICK); | |
} | |
}); | |
mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { | |
@Override | |
public void onRefresh() { | |
mCurrentPage++; | |
itemPos = 0; | |
loadMoreMessages(); | |
} | |
}); | |
} | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if (requestCode == GALLERY_PICK && resultCode == RESULT_OK) { | |
Uri imageUri = data.getData(); | |
final String current_user_ref = "messages/" + mCurrentUserId + "/" + mChatUser; | |
final String chat_user_ref = "messages/" + mChatUser + "/" + mCurrentUserId; | |
DatabaseReference user_message_push = mRootRef.child("messages") | |
.child(mCurrentUserId).child(mChatUser).push(); | |
final String push_id = user_message_push.getKey(); | |
StorageReference filepath = mImageStorage.child("message_images").child(push_id + ".jpg"); | |
filepath.putFile(imageUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() { | |
@Override | |
public void onComplete( Task<UploadTask.TaskSnapshot> task) { | |
if (task.isSuccessful()) { | |
String download_url = task.getResult().getDownloadUrl().toString(); | |
Map messageMap = new HashMap(); | |
messageMap.put("message", download_url); | |
messageMap.put("seen", false); | |
messageMap.put("type", "image"); | |
messageMap.put("time", ServerValue.TIMESTAMP); | |
messageMap.put("from", mCurrentUserId); | |
Map messageUserMap = new HashMap(); | |
messageUserMap.put(current_user_ref + "/" + push_id, messageMap); | |
messageUserMap.put(chat_user_ref + "/" + push_id, messageMap); | |
mChatMessageView.setText(""); | |
mRootRef.updateChildren(messageUserMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if (databaseError != null) { | |
Log.d("CHAT_LOG", databaseError.getMessage().toString()); | |
} | |
} | |
}); | |
} | |
} | |
}); | |
} | |
} | |
private void loadMoreMessages() { | |
DatabaseReference messageRef = mRootRef.child("messages").child(mCurrentUserId).child(mChatUser); | |
Query messageQuery = messageRef.orderByKey().endAt(mLastKey).limitToLast(10); | |
messageQuery.addChildEventListener(new ChildEventListener() { | |
@Override | |
public void onChildAdded(DataSnapshot dataSnapshot, String s) { | |
Messages message = dataSnapshot.getValue(Messages.class); | |
String messageKey = dataSnapshot.getKey(); | |
if(!mPrevKey.equals(messageKey)){ | |
messagesList.add(itemPos++, message); | |
}else { | |
mPrevKey = mLastKey; | |
} | |
if(itemPos == 1) { | |
mLastKey = messageKey; | |
} | |
Log.d("TOTALKEYS", "Last Key : " + mLastKey + " | Prev Key : " + mPrevKey + " | Message Key : " + messageKey); | |
mAdapter.notifyDataSetChanged(); | |
mRefreshLayout.setRefreshing(false); | |
mLinearLayout.scrollToPositionWithOffset(10, 0); | |
} | |
@Override | |
public void onChildChanged(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onChildRemoved(DataSnapshot dataSnapshot) { | |
} | |
@Override | |
public void onChildMoved(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
private void loadMessages() { | |
DatabaseReference messageRef=mRootRef.child("messages").child(mCurrentUserId).child(mChatUser); | |
Query messageQuery=messageRef.limitToLast(mCurrentPage*TOTAL_ITEMS_TO_LOAD); | |
messageQuery.addChildEventListener(new ChildEventListener() { | |
@Override | |
public void onChildAdded(DataSnapshot dataSnapshot, String s) { | |
Messages message=dataSnapshot.getValue(Messages.class); | |
itemPos++; | |
if(itemPos == 1){ | |
String messageKey = dataSnapshot.getKey(); | |
mLastKey = messageKey; | |
mPrevKey = messageKey; | |
} | |
messagesList.add(message); | |
mAdapter.notifyDataSetChanged(); | |
mMessageslist.scrollToPosition(messagesList.size()-1); | |
mRefreshLayout.setRefreshing(false); | |
} | |
@Override | |
public void onChildChanged(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onChildRemoved(DataSnapshot dataSnapshot) { | |
} | |
@Override | |
public void onChildMoved(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
private void sendMessage() { | |
String message=mChatMessageView.getText().toString(); | |
if(!TextUtils.isEmpty(message)){ | |
String current_user_ref="messages/" + mCurrentUserId + "/" + mChatUser; | |
String chat_user_ref="messages/" + mChatUser + "/" + mCurrentUserId; | |
DatabaseReference user_message_push=mRootRef.child("messages") | |
.child(mCurrentUserId).child(mChatUser).push(); | |
String push_id=user_message_push.getKey(); | |
Map messageMap=new HashMap(); | |
messageMap.put("message",message); | |
messageMap.put("seen",false); | |
messageMap.put("type","text"); | |
messageMap.put("time",ServerValue.TIMESTAMP); | |
messageMap.put("from",mCurrentUserId); | |
Map messageUserMap=new HashMap(); | |
messageUserMap.put(current_user_ref + "/" + push_id,messageMap); | |
messageUserMap.put(chat_user_ref + "/" + push_id,messageMap); | |
mChatMessageView.setText(""); | |
mRootRef.child("Chat").child(mCurrentUserId).child(mChatUser).child("seen").setValue(true); | |
mRootRef.child("Chat").child(mCurrentUserId).child(mChatUser).child("timestamp").setValue(ServerValue.TIMESTAMP); | |
mRootRef.child("Chat").child(mChatUser).child(mCurrentUserId).child("seen").setValue(false); | |
mRootRef.child("Chat").child(mChatUser).child(mCurrentUserId).child("timestamp").setValue(ServerValue.TIMESTAMP); | |
mRootRef.updateChildren(messageUserMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if(databaseError!=null){ | |
Log.d("Chat Log",databaseError.getMessage().toString()); | |
} | |
} | |
}); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.graphics.Typeface; | |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.support.v7.widget.LinearLayoutManager; | |
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.firebase.ui.database.FirebaseRecyclerAdapter; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.ChildEventListener; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.Query; | |
import com.google.firebase.database.ValueEventListener; | |
import com.squareup.picasso.Picasso; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
/** | |
* A simple {@link Fragment} subclass. | |
*/ | |
public class ChatsFragment extends Fragment { | |
private RecyclerView mConvList; | |
private DatabaseReference mConvDatabase; | |
private DatabaseReference mMessageDatabase; | |
private DatabaseReference mUsersDatabase; | |
private FirebaseAuth mAuth; | |
private String mCurrent_user_id; | |
private View mMainView; | |
public ChatsFragment() { | |
// Required empty public constructor | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
// Inflate the layout for this fragment' | |
mMainView = inflater.inflate(R.layout.fragment_chats, container, false); | |
mConvList = (RecyclerView) mMainView.findViewById(R.id.conv_list); | |
mAuth = FirebaseAuth.getInstance(); | |
mCurrent_user_id = mAuth.getCurrentUser().getUid(); | |
mConvDatabase = FirebaseDatabase.getInstance().getReference().child("Chat").child(mCurrent_user_id); | |
mConvDatabase.keepSynced(true); | |
mUsersDatabase = FirebaseDatabase.getInstance().getReference().child("Users"); | |
mMessageDatabase = FirebaseDatabase.getInstance().getReference().child("messages").child(mCurrent_user_id); | |
mUsersDatabase.keepSynced(true); | |
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()); | |
linearLayoutManager.setReverseLayout(true); | |
linearLayoutManager.setStackFromEnd(true); | |
mConvList.setHasFixedSize(true); | |
mConvList.setLayoutManager(linearLayoutManager); | |
// Inflate the layout for this fragment | |
return mMainView; | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
Query conversationQuery = mConvDatabase.orderByChild("timestamp"); | |
FirebaseRecyclerAdapter<Conv, ConvViewHolder> firebaseConvAdapter = new FirebaseRecyclerAdapter<Conv, ConvViewHolder>( | |
Conv.class, | |
R.layout.users_single_layout, | |
ConvViewHolder.class, | |
conversationQuery | |
) { | |
@Override | |
protected void populateViewHolder(final ConvViewHolder convViewHolder, final Conv conv, int i) { | |
final String list_user_id = getRef(i).getKey(); | |
Query lastMessageQuery = mMessageDatabase.child(list_user_id).limitToLast(1); | |
lastMessageQuery.addChildEventListener(new ChildEventListener() { | |
@Override | |
public void onChildAdded(DataSnapshot dataSnapshot, String s) { | |
String data = dataSnapshot.child("message").getValue().toString(); | |
convViewHolder.setMessage(data, conv.isSeen()); | |
} | |
@Override | |
public void onChildChanged(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onChildRemoved(DataSnapshot dataSnapshot) { | |
} | |
@Override | |
public void onChildMoved(DataSnapshot dataSnapshot, String s) { | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
mUsersDatabase.child(list_user_id).addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
final String userName = dataSnapshot.child("name").getValue().toString(); | |
String userThumb = dataSnapshot.child("thumb_image").getValue().toString(); | |
if(dataSnapshot.hasChild("online")) { | |
String userOnline = dataSnapshot.child("online").getValue().toString(); | |
convViewHolder.setUserOnline(userOnline); | |
} | |
convViewHolder.setName(userName); | |
convViewHolder.setUserImage(userThumb, getContext()); | |
convViewHolder.mView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Intent chatIntent = new Intent(getContext(), ChatActivity.class); | |
chatIntent.putExtra("user_id", list_user_id); | |
chatIntent.putExtra("user_name", userName); | |
startActivity(chatIntent); | |
} | |
}); | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
}; | |
mConvList.setAdapter(firebaseConvAdapter); | |
} | |
public static class ConvViewHolder extends RecyclerView.ViewHolder { | |
View mView; | |
public ConvViewHolder(View itemView) { | |
super(itemView); | |
mView = itemView; | |
} | |
public void setMessage(String message, boolean isSeen){ | |
TextView userStatusView = (TextView) mView.findViewById(R.id.users_single_status); | |
userStatusView.setText(message); | |
if(!isSeen){ | |
userStatusView.setTypeface(userStatusView.getTypeface(), Typeface.BOLD); | |
} else { | |
userStatusView.setTypeface(userStatusView.getTypeface(), Typeface.NORMAL); | |
} | |
} | |
public void setName(String name){ | |
TextView userNameView = (TextView) mView.findViewById(R.id.users_single_name); | |
userNameView.setText(name); | |
} | |
public void setUserImage(String thumb_image, Context ctx){ | |
CircleImageView userImageView = (CircleImageView) mView.findViewById(R.id.users_single_image); | |
Picasso.with(ctx).load(thumb_image).placeholder(R.drawable.avatar).into(userImageView); | |
} | |
public void setUserOnline(String online_status) { | |
ImageView userOnlineView = (ImageView) mView.findViewById(R.id.user_single_online_icon); | |
if(online_status.equals("true")){ | |
userOnlineView.setVisibility(View.VISIBLE); | |
} else { | |
userOnlineView.setVisibility(View.INVISIBLE); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
/** | |
* Created by harsh on 05-01-2018. | |
*/ | |
public class Conv { | |
public boolean seen; | |
public long timestamp; | |
public Conv(){ | |
} | |
public boolean isSeen() { | |
return seen; | |
} | |
public void setSeen(boolean seen) { | |
this.seen = seen; | |
} | |
public long getTimestamp() { | |
return timestamp; | |
} | |
public void setTimestamp(long timestamp) { | |
this.timestamp = timestamp; | |
} | |
public Conv(boolean seen, long timestamp) { | |
this.seen = seen; | |
this.timestamp = timestamp; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.NotificationManager; | |
import android.app.PendingIntent; | |
import android.content.Intent; | |
import android.support.v4.app.NotificationCompat; | |
import com.google.firebase.messaging.RemoteMessage; | |
/** | |
* Created by harsh on 29-12-2017. | |
*/ | |
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService { | |
@Override | |
public void onMessageReceived(RemoteMessage remoteMessage) { | |
super.onMessageReceived(remoteMessage); | |
String notification_title = remoteMessage.getNotification().getTitle(); | |
String notification_message = remoteMessage.getNotification().getBody(); | |
String click_action = remoteMessage.getNotification().getClickAction(); | |
String from_user_id = remoteMessage.getData().get("from_user_id"); | |
NotificationCompat.Builder mBuilder = | |
new NotificationCompat.Builder(this) | |
.setSmallIcon(R.mipmap.ic_launch) | |
.setContentTitle(notification_title) | |
.setContentText(notification_message); | |
Intent resultIntent = new Intent(click_action); | |
resultIntent.putExtra("user_id", from_user_id); | |
PendingIntent resultPendingIntent = | |
PendingIntent.getActivity( | |
this, | |
0, | |
resultIntent, | |
PendingIntent.FLAG_UPDATE_CURRENT | |
); | |
mBuilder.setContentIntent(resultPendingIntent); | |
int mNotificationId = (int) System.currentTimeMillis(); | |
NotificationManager mNotifyMgr = | |
(NotificationManager) getSystemService(NOTIFICATION_SERVICE); | |
mNotifyMgr.notify(mNotificationId, mBuilder.build()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.Application; | |
import android.content.Intent; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ServerValue; | |
import com.google.firebase.database.ValueEventListener; | |
import com.squareup.picasso.OkHttpDownloader; | |
import com.squareup.picasso.Picasso; | |
/** | |
* Created by harsh on 27-12-2017. | |
*/ | |
public class FreeChat extends Application { | |
private DatabaseReference mUserDatabase; | |
private FirebaseAuth mAuth; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
FirebaseDatabase.getInstance().setPersistenceEnabled(true); | |
Picasso.Builder builder=new Picasso.Builder(this); | |
builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE)); | |
Picasso built=builder.build(); | |
built.setIndicatorsEnabled(true); | |
built.setLoggingEnabled(true); | |
Picasso.setSingletonInstance(built); | |
mAuth = FirebaseAuth.getInstance(); | |
if(mAuth.getCurrentUser()!=null) { | |
mUserDatabase = FirebaseDatabase.getInstance() | |
.getReference().child("Users").child(mAuth.getCurrentUser().getUid()); | |
mUserDatabase.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if (dataSnapshot != null) { | |
mUserDatabase.child("online").onDisconnect().setValue(ServerValue.TIMESTAMP); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
/** | |
* Created by harsh on 29-12-2017. | |
*/ | |
public class Friends { | |
public String date; | |
public Friends(){ | |
} | |
public Friends(String date) { | |
this.date = date; | |
} | |
public String getDate() { | |
return date; | |
} | |
public void setDate(String date) { | |
this.date = date; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.support.v7.app.AlertDialog; | |
import android.support.v7.widget.LinearLayoutManager; | |
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.firebase.ui.database.FirebaseRecyclerAdapter; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ValueEventListener; | |
import com.squareup.picasso.Picasso; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
/** | |
* A simple {@link Fragment} subclass. | |
*/ | |
public class FriendsFragment extends Fragment { | |
private RecyclerView mFriendsList; | |
private DatabaseReference mFriendsDatabase; | |
private DatabaseReference mUsersDatabase; | |
private FirebaseAuth mAuth; | |
private String mCurrent_user_id; | |
private View mMainView; | |
public FriendsFragment() { | |
// Required empty public constructor | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
// Inflate the layout for this fragment | |
mMainView = inflater.inflate(R.layout.fragment_friends, container, false); | |
mFriendsList = (RecyclerView) mMainView.findViewById(R.id.friends_list); | |
mAuth = FirebaseAuth.getInstance(); | |
mCurrent_user_id = mAuth.getCurrentUser().getUid(); | |
mFriendsDatabase = FirebaseDatabase.getInstance().getReference().child("Friends").child(mCurrent_user_id); | |
mFriendsDatabase.keepSynced(true); | |
mUsersDatabase = FirebaseDatabase.getInstance().getReference().child("Users"); | |
mUsersDatabase.keepSynced(true); | |
mFriendsList.setHasFixedSize(true); | |
mFriendsList.setLayoutManager(new LinearLayoutManager(getContext())); | |
// Inflate the layout for this fragment | |
return mMainView; | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
FirebaseRecyclerAdapter<Friends, FriendsViewHolder> friendsRecyclerViewAdapter = new FirebaseRecyclerAdapter<Friends, FriendsViewHolder>( | |
Friends.class, | |
R.layout.users_single_layout, | |
FriendsViewHolder.class, | |
mFriendsDatabase | |
) { | |
@Override | |
protected void populateViewHolder(final FriendsViewHolder friendsViewHolder, final Friends friends, int i) { | |
friendsViewHolder.setDate(friends.getDate()); | |
final String list_user_id=getRef(i).getKey(); | |
mUsersDatabase.child(list_user_id).addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
final String userName = dataSnapshot.child("name").getValue().toString(); | |
String userThumb = dataSnapshot.child("thumb_image").getValue().toString(); | |
if (dataSnapshot.hasChild("online")) { | |
String userOnline = dataSnapshot.child("online").getValue().toString(); | |
friendsViewHolder.setUserOnline(userOnline); | |
} | |
friendsViewHolder.setName(userName); | |
friendsViewHolder.setUserImage(userThumb, getContext()); | |
friendsViewHolder.mView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
CharSequence options[]=new CharSequence[]{"Open Profile","Send Message"}; | |
AlertDialog.Builder builder= new AlertDialog.Builder(getContext()); | |
builder.setTitle("Select Options"); | |
builder.setItems(options, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
//Click Event | |
if(i==0){ | |
Intent profile_Intent=new Intent(getContext(),ProfileActivity.class); | |
profile_Intent.putExtra("user_id", list_user_id); | |
startActivity(profile_Intent); | |
} | |
if(i==1){ | |
Intent chat_Intent=new Intent(getContext(),ChatActivity.class); | |
chat_Intent.putExtra("user_id", list_user_id); | |
chat_Intent.putExtra("user_name",userName); | |
startActivity(chat_Intent); | |
} | |
} | |
}); | |
builder.show(); | |
} | |
}); | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
}; | |
mFriendsList.setAdapter(friendsRecyclerViewAdapter); | |
} | |
public static class FriendsViewHolder extends RecyclerView.ViewHolder { | |
View mView; | |
public FriendsViewHolder(View itemView) { | |
super(itemView); | |
mView = itemView; | |
} | |
public void setDate(String date) { | |
TextView userStatusView = (TextView) mView.findViewById(R.id.users_single_status); | |
userStatusView.setText(date); | |
} | |
public void setName(String name) { | |
TextView userNameView=mView.findViewById(R.id.users_single_name); | |
userNameView.setText(name); | |
} | |
public void setUserImage(String thumb_image, Context ctx) | |
{ | |
CircleImageView userImageView=mView.findViewById(R.id.users_single_image); | |
Picasso.with(ctx).load(thumb_image).placeholder(R.drawable.avatar).into(userImageView); | |
} | |
public void setUserOnline(String online_status) | |
{ | |
ImageView userOnlineView=mView.findViewById(R.id.user_single_online_icon); | |
if(online_status.equals("true")) | |
{ | |
userOnlineView.setVisibility(View.VISIBLE); | |
} | |
else | |
{ | |
userOnlineView.setVisibility(View.INVISIBLE); | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.Application; | |
import android.content.Context; | |
/** | |
* Created by harsh on 31-12-2017. | |
*/ | |
public class GetTimeAgo extends Application { | |
private static final int SECOND_MILLIS = 1000; | |
private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS; | |
private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS; | |
private static final int DAY_MILLIS = 24 * HOUR_MILLIS; | |
public static String getTimeAgo(long time, Context ctx) { | |
if (time < 1000000000000L) { | |
// if timestamp given in seconds, convert to millis | |
time *= 1000; | |
} | |
long now = System.currentTimeMillis(); | |
if (time > now || time <= 0) { | |
return null; | |
} | |
// TODO: localize | |
final long diff = now - time; | |
if (diff < MINUTE_MILLIS) { | |
return "just now"; | |
} else if (diff < 2 * MINUTE_MILLIS) { | |
return "a minute ago"; | |
} else if (diff < 50 * MINUTE_MILLIS) { | |
return diff / MINUTE_MILLIS + " minutes ago"; | |
} else if (diff < 90 * MINUTE_MILLIS) { | |
return "an hour ago"; | |
} else if (diff < 24 * HOUR_MILLIS) { | |
return diff / HOUR_MILLIS + " hours ago"; | |
} else if (diff < 48 * HOUR_MILLIS) { | |
return "yesterday"; | |
} else { | |
return diff / DAY_MILLIS + " days ago"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.TextInputLayout; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.Toolbar; | |
import android.text.TextUtils; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.OnSuccessListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.AuthResult; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.iid.FirebaseInstanceId; | |
public class LoginActivity extends AppCompatActivity { | |
private Toolbar mToolbar; | |
private TextInputLayout mLoginEmail; | |
private TextInputLayout mLoginPassword; | |
private Button mLogin_btn; | |
private ProgressDialog mLoginProgress; | |
private FirebaseAuth mAuth; | |
private DatabaseReference mUserDatabase; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_login); | |
mAuth = FirebaseAuth.getInstance(); | |
mToolbar=findViewById(R.id.login_toolbar); | |
setSupportActionBar(mToolbar); | |
getSupportActionBar().setTitle("Login"); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
mLoginProgress= new ProgressDialog(this); | |
mUserDatabase= FirebaseDatabase.getInstance().getReference().child("Users"); | |
mLoginEmail=findViewById(R.id.login_in_mail); | |
mLoginPassword=findViewById(R.id.login_in_pass); | |
mLogin_btn=findViewById(R.id.login_button); | |
mLogin_btn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
String email=mLoginEmail.getEditText().getText().toString(); | |
String password=mLoginPassword.getEditText().getText().toString(); | |
if(!TextUtils.isEmpty(email)|| !TextUtils.isEmpty(password)) | |
{ | |
mLoginProgress.setTitle("Logging In"); | |
mLoginProgress.setMessage("Please wait while we check your credentials."); | |
mLoginProgress.setCanceledOnTouchOutside(false); | |
mLoginProgress.show(); | |
loginUser(email,password); | |
} | |
} | |
}); | |
} | |
private void loginUser(String email, String password) { | |
mAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() { | |
@Override | |
public void onComplete(@NonNull Task<AuthResult> task) { | |
if(task.isSuccessful()) | |
{ | |
mLoginProgress.dismiss(); | |
String current_user_id=mAuth.getCurrentUser().getUid(); | |
String deviceToken= FirebaseInstanceId.getInstance().getToken(); | |
mUserDatabase.child(current_user_id).child("device_token").setValue(deviceToken).addOnSuccessListener(new OnSuccessListener<Void>() { | |
@Override | |
public void onSuccess(Void aVoid) { | |
Intent mainIntent=new Intent(LoginActivity.this,MainActivity.class); | |
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | |
startActivity(mainIntent); | |
finish(); | |
} | |
}); | |
} | |
else | |
{ | |
mLoginProgress.hide(); | |
Toast.makeText(LoginActivity.this, "Failed to Sign in.Please try again", | |
Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Intent; | |
import android.support.design.widget.TabLayout; | |
import android.support.v4.view.ViewPager; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import android.widget.TextView; | |
import android.widget.Toolbar; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.auth.FirebaseUser; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ServerValue; | |
public class MainActivity extends AppCompatActivity { | |
private FirebaseAuth mAuth; | |
private android.support.v7.widget.Toolbar mToolbar; | |
private ViewPager mViewPager; | |
private SectionsPagerAdapter mSectionsPagerAdapter; | |
private DatabaseReference mUserRef; | |
private TabLayout mTablayout; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mAuth = FirebaseAuth.getInstance(); | |
mToolbar=findViewById(R.id.main_page_toolbar); | |
setSupportActionBar(mToolbar); | |
getSupportActionBar().setTitle("Free Chat"); | |
if(mAuth.getCurrentUser()!=null) { | |
mUserRef = FirebaseDatabase.getInstance().getReference().child("Users").child(mAuth.getCurrentUser().getUid()); | |
} | |
mViewPager=findViewById(R.id.main_tabPager); | |
mSectionsPagerAdapter= new SectionsPagerAdapter(getSupportFragmentManager()); | |
mViewPager.setAdapter(mSectionsPagerAdapter); | |
mTablayout=findViewById(R.id.main_tabs); | |
mTablayout.setupWithViewPager(mViewPager); | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
// Check if user is signed in (non-null) and update UI accordingly. | |
FirebaseUser currentUser = mAuth.getCurrentUser(); | |
if (currentUser == null) { | |
sendtoStart(); | |
} else{ | |
mUserRef.child("online").setValue("true"); | |
} | |
} | |
protected void onStop() { | |
super.onStop(); | |
FirebaseUser currentUser = mAuth.getCurrentUser(); | |
if (currentUser!=null) { | |
mUserRef.child("online").setValue(ServerValue.TIMESTAMP); | |
} | |
} | |
private void sendtoStart() { | |
Intent startIntent=new Intent(MainActivity.this,StartActivity.class); | |
startActivity(startIntent); | |
finish(); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
super.onCreateOptionsMenu(menu); | |
getMenuInflater().inflate(R.menu.main_menu,menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
super.onOptionsItemSelected(item); | |
if(item.getItemId()==R.id.main_logout_btn){ | |
FirebaseAuth.getInstance().signOut(); | |
sendtoStart(); | |
} | |
if(item.getItemId()==R.id.main_settings_btn){ | |
Intent settingsintent=new Intent(MainActivity.this,SettingsActivity.class); | |
startActivity(settingsintent); | |
} | |
if(item.getItemId()==R.id.main_all_btn) | |
{ | |
Intent settingsintent=new Intent(MainActivity.this,UsersActivity.class); | |
startActivity(settingsintent); | |
} | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.graphics.Color; | |
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.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ValueEventListener; | |
import com.squareup.picasso.Picasso; | |
import java.util.List; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
/** | |
* Created by harsh on 01-01-2018. | |
*/ | |
public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder>{ | |
private List<Messages> mMessageList; | |
private FirebaseAuth mAuth; | |
private DatabaseReference mUserDatabase; | |
public MessageAdapter(List<Messages> mMessageList) { | |
this.mMessageList = mMessageList; | |
} | |
@Override | |
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View v = LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.message_single_layout ,parent, false); | |
return new MessageViewHolder(v); | |
} | |
public class MessageViewHolder extends RecyclerView.ViewHolder { | |
public TextView messageText; | |
public CircleImageView profileImage; | |
public TextView displayName; | |
public ImageView messageImage; | |
public MessageViewHolder(View view) { | |
super(view); | |
messageText = (TextView) view.findViewById(R.id.message_text_layout); | |
profileImage = (CircleImageView) view.findViewById(R.id.message_profile_layout); | |
displayName = (TextView) view.findViewById(R.id.name_text_layout); | |
messageImage = (ImageView) view.findViewById(R.id.message_image_layout); | |
} | |
} | |
@Override | |
public void onBindViewHolder(final MessageViewHolder viewHolder, int i) { | |
Messages c = mMessageList.get(i); | |
String from_user = c.getFrom(); | |
String message_type = c.getType(); | |
mUserDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(from_user); | |
mUserDatabase.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
String name = dataSnapshot.child("name").getValue().toString(); | |
String image = dataSnapshot.child("thumb_image").getValue().toString(); | |
viewHolder.displayName.setText(name); | |
Picasso.with(viewHolder.profileImage.getContext()).load(image) | |
.placeholder(R.drawable.avatar).into(viewHolder.profileImage); | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
if(message_type.equals("text")) { | |
viewHolder.messageText.setText(c.getMessage()); | |
viewHolder.messageImage.setVisibility(View.INVISIBLE); | |
} else { | |
viewHolder.messageText.setVisibility(View.INVISIBLE); | |
Picasso.with(viewHolder.profileImage.getContext()).load(c.getMessage()) | |
.placeholder(R.drawable.avatar).into(viewHolder.messageImage); | |
} | |
} | |
@Override | |
public int getItemCount() { | |
return mMessageList.size(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
/** | |
* Created by harsh on 01-01-2018. | |
*/ | |
public class Messages { | |
private String message, type; | |
private long time; | |
private boolean seen; | |
private String from; | |
public Messages(String from) { | |
this.from = from; | |
} | |
public String getFrom() { | |
return from; | |
} | |
public void setFrom(String from) { | |
this.from = from; | |
} | |
public Messages(String message, String type, long time, boolean seen) { | |
this.message = message; | |
this.type = type; | |
this.time = time; | |
this.seen = seen; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public String getType() { | |
return type; | |
} | |
public void setType(String type) { | |
this.type = type; | |
} | |
public long getTime() { | |
return time; | |
} | |
public void setTime(long time) { | |
this.time = time; | |
} | |
public boolean isSeen() { | |
return seen; | |
} | |
public void setSeen(boolean seen) { | |
this.seen = seen; | |
} | |
public Messages(){ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.ProgressDialog; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.OnSuccessListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.auth.FirebaseUser; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ValueEventListener; | |
import com.squareup.picasso.Picasso; | |
import java.text.DateFormat; | |
import java.util.Date; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class ProfileActivity extends AppCompatActivity { | |
private ImageView mProfileImage; | |
private TextView mProfileName,mProfileStatus; | |
private Button mProfileSendReqBtn, mDeclineBtn; | |
private DatabaseReference mUsersDatabase; | |
private ProgressDialog mProgressDialog; | |
private DatabaseReference mFriendReqDatabase; | |
private DatabaseReference mFriendDatabase; | |
private DatabaseReference mNotificationDatabase; | |
private DatabaseReference mRootRef; | |
private FirebaseUser mCurrent_user; | |
private String mcurrent_state; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_profile); | |
final String user_id=getIntent().getStringExtra("user_id"); | |
mRootRef=FirebaseDatabase.getInstance().getReference(); | |
mUsersDatabase= FirebaseDatabase.getInstance().getReference().child("Users").child(user_id); | |
mFriendReqDatabase = FirebaseDatabase.getInstance().getReference().child("Friend_req"); | |
mFriendDatabase=FirebaseDatabase.getInstance().getReference().child("Friends"); | |
mNotificationDatabase=FirebaseDatabase.getInstance().getReference().child("notifications"); | |
mCurrent_user=FirebaseAuth.getInstance().getCurrentUser(); | |
mProfileImage=findViewById(R.id.profile_picture); | |
mProfileName=findViewById(R.id.profile_displayName); | |
mProfileStatus=findViewById(R.id.profile_status); | |
mProfileSendReqBtn=findViewById(R.id.profile_send_req_btn); | |
mDeclineBtn=findViewById(R.id.profile_decline_btn); | |
mcurrent_state="not_friends"; | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
mProgressDialog=new ProgressDialog(this); | |
mProgressDialog.setTitle("Loading Users Data"); | |
mProgressDialog.setMessage("Please wait while we load user data"); | |
mProgressDialog.setCanceledOnTouchOutside(false); | |
mProgressDialog.show(); | |
mUsersDatabase.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
String display_name=dataSnapshot.child("name").getValue().toString(); | |
String status=dataSnapshot.child("status").getValue().toString(); | |
String image=dataSnapshot.child("image").getValue().toString(); | |
mProfileName.setText(display_name); | |
mProfileStatus.setText(status); | |
Picasso.with(ProfileActivity.this).load(image).placeholder(R.drawable.default_avatar).into(mProfileImage); | |
//---------------FRIENDS LIST/REQUEST FEATURE-------------- | |
mFriendReqDatabase.child(mCurrent_user.getUid()).addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if(dataSnapshot.hasChild(user_id)){ | |
String req_type=dataSnapshot.child(user_id).child("request_type").getValue().toString(); | |
if(req_type.equals("received")){ | |
mcurrent_state="req_received"; | |
mProfileSendReqBtn.setText("Accept Friend Request"); | |
mDeclineBtn.setVisibility(View.VISIBLE); | |
mDeclineBtn.setEnabled(true); | |
} else if(req_type.equals("sent")){ | |
mcurrent_state="req_sent"; | |
mProfileSendReqBtn.setText("Cancel Friend Request"); | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
} | |
mProgressDialog.dismiss(); | |
} | |
else{ | |
mFriendDatabase.child(mCurrent_user.getUid()).addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
if(dataSnapshot.hasChild(user_id)){ | |
mcurrent_state="friends"; | |
mProfileSendReqBtn.setText("Unfriend this person"); | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
} | |
mProgressDialog.dismiss(); | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
mProgressDialog.dismiss(); | |
} | |
}); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
mProfileSendReqBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
mProfileSendReqBtn.setEnabled(false); | |
//--------------NOT FRIENDS STATE--------------- | |
if(mcurrent_state.equals("not_friends")) | |
{ | |
DatabaseReference newNotificationref=mRootRef.child("notifications").child(user_id).push(); | |
String newNotificationId=newNotificationref.getKey(); | |
HashMap<String,String> notificationData=new HashMap<>(); | |
notificationData.put("from",mCurrent_user.getUid()); | |
notificationData.put("type","request"); | |
Map requestMap=new HashMap(); | |
requestMap.put("Friend_req/" + mCurrent_user.getUid()+ "/" + user_id + "/request_type","sent"); | |
requestMap.put("Friend_req/" + user_id + "/" + mCurrent_user.getUid() + "/request_type","received"); | |
requestMap.put("notifications/"+ user_id + "/" + newNotificationId,notificationData); | |
mRootRef.updateChildren(requestMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if(databaseError !=null) | |
{ | |
Toast.makeText(ProfileActivity.this,"There was some error in sending request",Toast.LENGTH_SHORT).show(); | |
} | |
mProfileSendReqBtn.setEnabled(true); | |
mcurrent_state="req_sent"; | |
mProfileSendReqBtn.setText("Cancel Friend Request"); | |
} | |
}); | |
} | |
//-----------CANCEL REQUEST STATE-------------- | |
if(mcurrent_state.equals("req_sent")) | |
{ | |
mFriendReqDatabase.child(mCurrent_user.getUid()).child(user_id).removeValue().addOnSuccessListener(new OnSuccessListener<Void>() { | |
@Override | |
public void onSuccess(Void aVoid) { | |
mFriendReqDatabase.child(user_id).child(mCurrent_user.getUid()).removeValue().addOnSuccessListener(new OnSuccessListener<Void>() { | |
@Override | |
public void onSuccess(Void aVoid) { | |
mProfileSendReqBtn.setEnabled(true); | |
mcurrent_state="not_friends"; | |
mProfileSendReqBtn.setText("Send Friend Request"); | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
} | |
}); | |
} | |
}); | |
} | |
//----------REQUEST RECEIVED STATE-------------- | |
if(mcurrent_state.equals("req_received")){ | |
final String currentDate= DateFormat.getDateTimeInstance().format(new Date()); | |
Map friendsMap=new HashMap(); | |
friendsMap.put("Friends/" + mCurrent_user.getUid() + "/" + user_id + "/date", currentDate); | |
friendsMap.put("Friends/" + user_id + "/" + mCurrent_user.getUid() + "/date",currentDate); | |
friendsMap.put("Friend_req/" + mCurrent_user.getUid() + "/" + user_id,null); | |
friendsMap.put("Friend_req/" + user_id + "/" + mCurrent_user.getUid(),null); | |
mRootRef.updateChildren(friendsMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if(databaseError==null) | |
{ | |
mProfileSendReqBtn.setEnabled(true); | |
mcurrent_state="friends"; | |
mProfileSendReqBtn.setText("Unfriend this person"); | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
} | |
else | |
{ | |
String error=databaseError.getMessage(); | |
Toast.makeText(ProfileActivity.this,error,Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
} | |
//---------UNFRIEND------------ | |
if(mcurrent_state.equals("friends")) | |
{ | |
Map unfriendMap=new HashMap(); | |
unfriendMap.put("Friends/" + mCurrent_user.getUid() + "/" + user_id,null); | |
unfriendMap.put("Friends/" + user_id + "/" + mCurrent_user.getUid(),null); | |
mRootRef.updateChildren(unfriendMap, new DatabaseReference.CompletionListener() { | |
@Override | |
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { | |
if(databaseError==null) | |
{ | |
mcurrent_state="not_friends"; | |
mProfileSendReqBtn.setText("Send Friend Request"); | |
mDeclineBtn.setVisibility(View.INVISIBLE); | |
mDeclineBtn.setEnabled(false); | |
} | |
else | |
{ | |
String error=databaseError.getMessage(); | |
Toast.makeText(ProfileActivity.this,error,Toast.LENGTH_SHORT).show(); | |
} | |
mProfileSendReqBtn.setEnabled(true); | |
} | |
}); | |
} | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.TextInputLayout; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.Toolbar; | |
import android.text.TextUtils; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.AuthResult; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.auth.FirebaseUser; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.iid.FirebaseInstanceId; | |
import java.util.HashMap; | |
public class RegisterActivity extends AppCompatActivity { | |
private TextInputLayout mDisplayname; | |
private TextInputLayout mEmail; | |
private TextInputLayout mPassword; | |
private Button mCreateBtn; | |
private Toolbar mToolbar; | |
private DatabaseReference mDatabase; | |
private ProgressDialog mRegProgress; | |
private FirebaseAuth mAuth; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_register); | |
mToolbar=findViewById(R.id.register_toolbar); | |
setSupportActionBar(mToolbar); | |
getSupportActionBar().setTitle("Create Account"); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
mRegProgress=new ProgressDialog(this); | |
mAuth = FirebaseAuth.getInstance(); | |
mDisplayname=findViewById(R.id.textInputLayout5); | |
mEmail=findViewById(R.id.textInputLayout6); | |
mPassword=findViewById(R.id.textInputLayout4); | |
mCreateBtn=findViewById(R.id.reg_create_btn); | |
mCreateBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
String display_name=mDisplayname.getEditText().getText().toString(); | |
String email=mEmail.getEditText().getText().toString(); | |
String password=mPassword.getEditText().getText().toString(); | |
if(!TextUtils.isEmpty(display_name) || !TextUtils.isEmpty(email) || !TextUtils.isEmpty(password)) | |
{ | |
mRegProgress.setTitle("Registering User"); | |
mRegProgress.setMessage("Please wait while we create your account !"); | |
mRegProgress.setCanceledOnTouchOutside(false); | |
mRegProgress.show(); | |
register_user(display_name,email,password); | |
} | |
} | |
}); | |
} | |
private void register_user(final String display_name, String email, String password) { | |
mAuth.createUserWithEmailAndPassword(email, password) | |
.addOnCompleteListener( new OnCompleteListener<AuthResult>() { | |
@Override | |
public void onComplete(@NonNull Task<AuthResult> task) { | |
if (task.isSuccessful()) { | |
FirebaseUser current_user=FirebaseAuth.getInstance().getCurrentUser(); | |
String uid=current_user.getUid(); | |
mDatabase=FirebaseDatabase.getInstance().getReference().child("Users").child(uid); | |
String device_token = FirebaseInstanceId.getInstance().getToken(); | |
HashMap<String,String> usermap=new HashMap<>(); | |
usermap.put("name",display_name); | |
usermap.put("status","Hi there I'm using Free Chat App."); | |
usermap.put("image","default"); | |
usermap.put("thumb_image", "default"); | |
usermap.put("device_token", device_token); | |
mDatabase.setValue(usermap).addOnCompleteListener(new OnCompleteListener<Void>() { | |
@Override | |
public void onComplete(@NonNull Task<Void> task) { | |
if(task.isSuccessful()) | |
{ | |
mRegProgress.dismiss(); | |
// Sign in success, update UI with the signed-in user's information | |
Intent mainIntent=new Intent(RegisterActivity.this,MainActivity.class); | |
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | |
startActivity(mainIntent); | |
finish(); | |
} | |
} | |
}); | |
} else { | |
// If sign in fails, display a message to the user. | |
mRegProgress.hide(); | |
Toast.makeText(RegisterActivity.this, "Failed to Sign in.Please try again", | |
Toast.LENGTH_SHORT).show(); | |
} | |
// ... | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* A simple {@link Fragment} subclass. | |
*/ | |
public class RequestsFragment extends Fragment { | |
public RequestsFragment() { | |
// Required empty public constructor | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
// Inflate the layout for this fragment | |
return inflater.inflate(R.layout.fragment_requests, container, false); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentManager; | |
import android.support.v4.app.FragmentPagerAdapter; | |
/** | |
* Created by harsh on 24-12-2017. | |
*/ | |
class SectionsPagerAdapter extends FragmentPagerAdapter{ | |
public SectionsPagerAdapter(FragmentManager fm) { | |
super(fm); | |
} | |
@Override | |
public Fragment getItem(int position) { | |
switch(position){ | |
case 0: | |
RequestsFragment requestsFragment=new RequestsFragment(); | |
return requestsFragment; | |
case 1: | |
ChatsFragment chatsFragment=new ChatsFragment(); | |
return chatsFragment; | |
case 2: | |
FriendsFragment friendsFragment=new FriendsFragment(); | |
return friendsFragment; | |
default: | |
return null; | |
} | |
} | |
@Override | |
public int getCount() { | |
return 3; | |
} | |
public CharSequence getPageTitle(int position){ | |
switch(position){ | |
case 0: | |
return "REQUESTS"; | |
case 1: | |
return "CHATS"; | |
case 2: | |
return "FRIENDS"; | |
default: | |
return null; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.graphics.Bitmap; | |
import android.net.Uri; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.auth.FirebaseUser; | |
import com.google.firebase.database.DataSnapshot; | |
import com.google.firebase.database.DatabaseError; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.google.firebase.database.ValueEventListener; | |
import com.google.firebase.storage.FirebaseStorage; | |
import com.google.firebase.storage.StorageReference; | |
import com.google.firebase.storage.UploadTask; | |
import com.squareup.picasso.Callback; | |
import com.squareup.picasso.NetworkPolicy; | |
import com.squareup.picasso.Picasso; | |
//import com.theartofdev.edmodo.cropper.CropImage; | |
//import com.theartofdev.edmodo.cropper.CropImageView; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Random; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
//import id.zelory.compressor.Compressor; | |
public class SettingsActivity extends AppCompatActivity { | |
private DatabaseReference mUserDatabase; | |
private FirebaseUser mCurrentUser; | |
private CircleImageView mDisplayImage; | |
private TextView mName; | |
private TextView mStatus; | |
private Button mStatusBtn; | |
private Button mImageBtn; | |
private static final int GALLERY_PIC=1; | |
private StorageReference mImageStorage; | |
private ProgressDialog mProgressDialog; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_settings); | |
mDisplayImage=findViewById(R.id.settings_dp); | |
mName=findViewById(R.id.settings_name); | |
mStatus=findViewById(R.id.settings_status); | |
mStatusBtn=findViewById(R.id.settings_status_btn); | |
mImageBtn=findViewById(R.id.settings_image_btn); | |
mImageStorage= FirebaseStorage.getInstance().getReference(); | |
mCurrentUser= FirebaseAuth.getInstance().getCurrentUser(); | |
String current_uid=mCurrentUser.getUid(); | |
mUserDatabase= FirebaseDatabase.getInstance().getReference().child("Users").child(current_uid); | |
mUserDatabase.keepSynced(true); | |
mUserDatabase.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
String name=dataSnapshot.child("name").getValue().toString(); | |
final String image=dataSnapshot.child("image").getValue().toString(); | |
String status=dataSnapshot.child("status").getValue().toString(); | |
String thumb_image=dataSnapshot.child("thumb_image").getValue().toString(); | |
mName.setText(name); | |
mStatus.setText(status); | |
if(!image.equals("default")){ | |
// Picasso.with(SettingsActivity.this).load(image).placeholder(R.drawable.avatar).into(mDisplayImage); | |
Picasso.with(SettingsActivity.this).load(image).networkPolicy(NetworkPolicy.OFFLINE) | |
.placeholder(R.drawable.avatar).into(mDisplayImage, new Callback() { | |
@Override | |
public void onSuccess() { | |
} | |
@Override | |
public void onError() { | |
Picasso.with(SettingsActivity.this).load(image).placeholder(R.drawable.avatar).into(mDisplayImage); | |
} | |
}); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
mStatusBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
String status_value=mStatus.getText().toString(); | |
Intent statusIntent=new Intent(SettingsActivity.this,StatusActivity.class); | |
statusIntent.putExtra("status value",status_value); | |
startActivity(statusIntent); | |
} | |
}); | |
mImageBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Intent gallery_intent = new Intent(); | |
gallery_intent.setType("image/*"); | |
gallery_intent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult(Intent.createChooser(gallery_intent, "SELECT IMAGE"), GALLERY_PIC); | |
} | |
}); | |
} | |
/* | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if(requestCode==GALLERY_PIC && resultCode==RESULT_OK) | |
{ | |
Uri imageUri=data.getData(); | |
CropImage.activity(imageUri) | |
.setAspectRatio(1,1) | |
.start(this); | |
} | |
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { | |
CropImage.ActivityResult result = CropImage.getActivityResult(data); | |
if (resultCode == RESULT_OK) { | |
mProgressDialog = new ProgressDialog(SettingsActivity.this); | |
mProgressDialog.setTitle("Uploading Image..."); | |
mProgressDialog.setMessage("Please wait while we upload and process the image."); | |
mProgressDialog.setCanceledOnTouchOutside(false); | |
mProgressDialog.show(); | |
Uri resultUri = result.getUri(); | |
File thumb_filePath = new File(resultUri.getPath()); | |
String current_user_id = mCurrentUser.getUid(); | |
Bitmap thumb_bitmap = null; | |
try { | |
thumb_bitmap = new Compressor(this) | |
.setMaxWidth(200) | |
.setMaxHeight(200) | |
.setQuality(75) | |
.compressToBitmap(thumb_filePath); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
thumb_bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); | |
final byte[] thumb_byte = baos.toByteArray(); | |
StorageReference filepath = mImageStorage.child("profile_images").child(current_user_id + ".jpg"); | |
final StorageReference thumb_filepath= mImageStorage.child("profile_images").child("thumbs").child(current_user_id+".jpg"); | |
filepath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() { | |
@Override | |
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) { | |
if (task.isSuccessful()) { | |
final String download_url = task.getResult().getDownloadUrl().toString(); | |
UploadTask uploadTask=thumb_filepath.putBytes(thumb_byte); | |
uploadTask.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() { | |
@Override | |
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> thumb_task) { | |
String thumb_downloadUrl=thumb_task.getResult().getDownloadUrl().toString(); | |
if(thumb_task.isSuccessful()){ | |
Map update_hashMap=new HashMap<>(); | |
update_hashMap.put("image", download_url); | |
update_hashMap.put("thumb_image",thumb_downloadUrl); | |
mUserDatabase.updateChildren(update_hashMap).addOnCompleteListener(new OnCompleteListener<Void>() { | |
@Override | |
public void onComplete(@NonNull Task<Void> task) { | |
if (task.isSuccessful()) { | |
mProgressDialog.dismiss(); | |
Toast.makeText(SettingsActivity.this, "Successfully Uploaded", Toast.LENGTH_LONG).show(); | |
} | |
} | |
}); | |
} | |
else | |
{ | |
Toast.makeText(SettingsActivity.this, "Error in Uploading", Toast.LENGTH_LONG).show(); | |
mProgressDialog.dismiss(); | |
} | |
} | |
}); | |
} else { | |
Toast.makeText(SettingsActivity.this, "Error in Uploading Thumbnail", Toast.LENGTH_LONG).show(); | |
mProgressDialog.dismiss(); | |
} | |
} | |
}); | |
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { | |
Exception error = result.getError(); | |
} | |
} | |
} | |
public static String random() { | |
Random generator = new Random(); | |
StringBuilder randomStringBuilder = new StringBuilder(); | |
int randomLength = generator.nextInt(10); | |
char tempChar; | |
for (int i = 0; i < randomLength; i++){ | |
tempChar = (char) (generator.nextInt(96) + 32); | |
randomStringBuilder.append(tempChar); | |
} | |
return randomStringBuilder.toString(); | |
}*/ | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
public class StartActivity extends AppCompatActivity { | |
private Button mRegBtn; | |
private Button mLoginBtn; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_start); | |
mRegBtn = findViewById(R.id.start_reg_btn); | |
mRegBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
boolean connected = false; | |
ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); | |
if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || | |
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) { | |
//we are connected to a network | |
connected = true; | |
} | |
else | |
connected = false; | |
if(connected) { | |
Intent RegisterIntent = new Intent(StartActivity.this, RegisterActivity.class); | |
startActivity(RegisterIntent); | |
} | |
else | |
Toast.makeText(StartActivity.this,"No Internet Connection",Toast.LENGTH_LONG).show(); | |
} | |
}); | |
mLoginBtn = findViewById(R.id.start_login_btn); | |
mLoginBtn.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View view) { | |
boolean connected = false; | |
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE). | |
getState() == NetworkInfo.State.CONNECTED || | |
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI). | |
getState() == NetworkInfo.State.CONNECTED) | |
{ | |
//we are connected to a network | |
connected = true; | |
} else | |
connected = false; | |
if (connected) | |
{ | |
Intent LoginInt = new Intent(StartActivity.this, LoginActivity.class); | |
startActivity(LoginInt); | |
} else | |
Toast.makeText(StartActivity.this, "No Internet Connection", Toast.LENGTH_LONG).show(); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.TextInputLayout; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.Toolbar; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.FirebaseAuth; | |
import com.google.firebase.auth.FirebaseUser; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
public class StatusActivity extends AppCompatActivity { | |
private Toolbar mToolbar; | |
private TextInputLayout mStatus; | |
private Button mSaveBtn; | |
private DatabaseReference mStatusDatabase; | |
private FirebaseUser mCurrentUser; | |
private ProgressDialog mProgress; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_status); | |
mCurrentUser= FirebaseAuth.getInstance().getCurrentUser(); | |
String current_uid=mCurrentUser.getUid(); | |
mStatusDatabase= FirebaseDatabase.getInstance().getReference().child("Users").child(current_uid); | |
mToolbar=findViewById(R.id.status_appBar); | |
setSupportActionBar(mToolbar); | |
getSupportActionBar().setTitle("Account Status"); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
String status_value=getIntent().getStringExtra("status value"); | |
mStatus=findViewById(R.id.status_input); | |
mSaveBtn=findViewById(R.id.update_stat_btn); | |
mStatus.getEditText().setText(status_value); | |
mSaveBtn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
mProgress=new ProgressDialog(StatusActivity.this); | |
mProgress.setTitle("Saving Changes"); | |
mProgress.setMessage("Please wait while we save the changes"); | |
mProgress.show(); | |
String status=mStatus.getEditText().getText().toString(); | |
mStatusDatabase.child("status").setValue(status).addOnCompleteListener(new OnCompleteListener<Void>() { | |
@Override | |
public void onComplete(@NonNull Task<Void> task) { | |
if(task.isSuccessful()) | |
{ | |
mProgress.dismiss(); | |
Intent SettingActivity=new Intent(StatusActivity.this,SettingsActivity.class); | |
startActivity(SettingActivity); | |
} | |
else | |
{ | |
Toast.makeText(getApplicationContext(),"There was some error in saving changes !", Toast.LENGTH_LONG).show(); | |
} | |
} | |
}); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
/** | |
* Created by harsh on 26-12-2017. | |
*/ | |
public class Users { | |
public String name; | |
public String image; | |
public String status; | |
public String thumb_image; | |
public Users(){ | |
} | |
public Users(String name, String image, String status) { | |
this.name = name; | |
this.image = image; | |
this.status = status; | |
this.thumb_image=thumb_image; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getImage() { | |
return image; | |
} | |
public void setImage(String image) { | |
this.image = image; | |
} | |
public String getStatus() { | |
return status; | |
} | |
public void setStatus(String status) { | |
this.status = status; | |
} | |
public String getThumb_image() {return thumb_image; } | |
public void setThumb_image(String thumb_image){ | |
this.thumb_image=thumb_image; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.harsh.freechat; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.Toolbar; | |
import android.view.View; | |
import android.widget.TextView; | |
import com.firebase.ui.database.FirebaseRecyclerAdapter; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
import com.squareup.picasso.Picasso; | |
import de.hdodenhof.circleimageview.CircleImageView; | |
public class UsersActivity extends AppCompatActivity { | |
private Toolbar mToolbar; | |
private RecyclerView mUsersList; | |
private DatabaseReference mUsersDatabase; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_users); | |
mToolbar=findViewById(R.id.users_appBar); | |
setSupportActionBar(mToolbar); | |
getSupportActionBar().setTitle("All Users"); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
mUsersDatabase= FirebaseDatabase.getInstance().getReference().child("Users"); | |
mUsersList=findViewById(R.id.users_list); | |
mUsersList.setHasFixedSize(true); | |
mUsersList.setLayoutManager(new LinearLayoutManager(this)); | |
} | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
FirebaseRecyclerAdapter<Users, UsersViewHolder> firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<Users, UsersViewHolder>( | |
Users.class, | |
R.layout.users_single_layout, | |
UsersViewHolder.class, | |
mUsersDatabase | |
) { | |
@Override | |
protected void populateViewHolder(UsersViewHolder viewHolder, Users users, int position) { | |
UsersViewHolder.setName(users.getName()); | |
UsersViewHolder.setUserStatus(users.getStatus()); | |
UsersViewHolder.setUserImage(users.getThumb_image(),getApplicationContext()); | |
final String user_id= getRef(position).getKey(); | |
UsersViewHolder.mView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Intent profile_Intent=new Intent(UsersActivity.this,ProfileActivity.class); | |
profile_Intent.putExtra("user_id", user_id); | |
startActivity(profile_Intent); | |
} | |
}); | |
} | |
}; | |
mUsersList.setAdapter(firebaseRecyclerAdapter); | |
} | |
public static class UsersViewHolder extends RecyclerView.ViewHolder{ | |
static View mView; | |
public UsersViewHolder(View itemView) { | |
super(itemView); | |
mView=itemView; | |
} | |
public static void setName(String name){ | |
TextView userNameView=mView.findViewById(R.id.users_single_name); | |
userNameView.setText(name); | |
} | |
public static void setUserStatus(String status){ | |
TextView userStatusView=mView.findViewById(R.id.users_single_status); | |
userStatusView.setText(status); | |
} | |
public static void setUserImage(String thumb_image, Context ctx) | |
{ | |
CircleImageView userImageView=mView.findViewById(R.id.users_single_image); | |
Picasso.with(ctx).load(thumb_image).placeholder(R.drawable.avatar).into(userImageView); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<solid android:color="@color/colorPrimary"/> | |
<corners android:radius="30dp"/> | |
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="#cccccc" | |
tools:context="com.example.harsh.freechat.ChatActivity"> | |
<include | |
android:id="@+id/chat_app_bar" | |
layout="@layout/app_bar_layout" /> | |
<android.support.v4.widget.SwipeRefreshLayout | |
android:id="@+id/message_swipe_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_above="@+id/linearLayout" | |
android:layout_alignParentStart="true" | |
android:layout_below="@+id/chat_app_bar"> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/messages_list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_above="@+id/linearLayout" | |
android:layout_alignParentStart="true" | |
android:layout_below="@+id/chat_app_bar"></android.support.v7.widget.RecyclerView> | |
</android.support.v4.widget.SwipeRefreshLayout> | |
<LinearLayout | |
android:id="@+id/linearLayout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_alignParentStart="true" | |
android:background="@android:color/white" | |
android:orientation="horizontal" | |
android:weightSum="10"> | |
<ImageButton | |
android:id="@+id/chat_add_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:alpha="0.5" | |
android:background="@android:color/white" | |
android:padding="10dp" | |
app:srcCompat="@drawable/ic_add_black_24dp" /> | |
<EditText | |
android:id="@+id/chat_message_view" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="8" | |
android:background="@android:color/white" | |
android:ems="10" | |
android:hint="Enter Message..." | |
android:inputType="textPersonName" | |
android:paddingBottom="12dp" | |
android:paddingLeft="10dp" | |
android:paddingRight="10dp" | |
android:paddingTop="14dp" /> | |
<ImageButton | |
android:id="@+id/chat_send_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_weight="1" | |
android:alpha="0.5" | |
android:background="@android:color/white" | |
android:padding="10dp" | |
app:srcCompat="@drawable/ic_send_black_24dp" /> | |
</LinearLayout> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.LoginActivity"> | |
<include layout="@layout/app_bar_layout" android:id="@+id/login_toolbar"/> | |
<TextView | |
android:id="@+id/textView3" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="8dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="44dp" | |
android:text="Sign-in" | |
android:textColor="@android:color/black" | |
android:textSize="25sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toTopOf="@+id/login_in_mail" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/login_toolbar" /> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/login_in_mail" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="160dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="@+id/login_toolbar"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Your Email" | |
android:inputType="textEmailAddress" /> | |
</android.support.design.widget.TextInputLayout> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/login_in_pass" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/login_in_mail"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="@string/password" | |
android:inputType="textPassword" /> | |
</android.support.design.widget.TextInputLayout> | |
<Button | |
android:id="@+id/login_button" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="85dp" | |
android:background="@color/colorAccent" | |
android:padding="20dp" | |
android:paddingLeft="25dp" | |
android:paddingRight="25dp" | |
android:text="Log_in" | |
android:textColor="@android:color/white" | |
android:textSize="15sp" | |
android:textStyle="bold" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/login_in_pass" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@android:color/white" | |
android:backgroundTint="@android:color/white" | |
tools:context="com.example.harsh.freechat.MainActivity"> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<include | |
android:id="@+id/main_page_toolbar" | |
layout="@layout/app_bar_layout" /> | |
<android.support.design.widget.TabLayout | |
android:id="@+id/main_tabs" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:backgroundTint="@android:color/white" | |
app:tabSelectedTextColor="@android:color/white" | |
app:tabTextColor="@color/colorAccent"> | |
</android.support.design.widget.TabLayout> | |
</android.support.design.widget.AppBarLayout> | |
<android.support.v4.view.ViewPager | |
android:id="@+id/main_tabPager" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="100dp" | |
app:layout_constraintTop_toTopOf="parent"></android.support.v4.view.ViewPager> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorPrimaryDark" | |
tools:context="com.example.harsh.freechat.ProfileActivity"> | |
<TextView | |
android:id="@+id/profile_displayName" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:layout_centerVertical="true" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="20dp" | |
android:text="@string/display_name" | |
android:textColor="@android:color/white" | |
android:textSize="30dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/profile_picture" /> | |
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/profile_picture" | |
android:layout_width="155sp" | |
android:layout_height="155sp" | |
android:layout_marginEnd="126dp" | |
android:layout_marginStart="126dp" | |
android:layout_marginTop="80dp" | |
android:src="@drawable/default_avatar" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<TextView | |
android:id="@+id/profile_status" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/profile_displayName" | |
android:layout_centerHorizontal="true" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="8dp" | |
android:text="@string/current_user_status" | |
android:textColor="@android:color/white" | |
android:textSize="18dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/profile_displayName" /> | |
<Button | |
android:id="@+id/profile_send_req_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignBaseline="@+id/profile_decline_btn" | |
android:layout_alignBottom="@+id/profile_decline_btn" | |
android:layout_marginBottom="128dp" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_toStartOf="@+id/profile_status" | |
android:background="@color/colorAccent" | |
android:padding="5dp" | |
android:paddingBottom="2dp" | |
android:paddingTop="2dp" | |
android:text="Send Friend Request" | |
android:textColor="@android:color/white" | |
android:textSize="12sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" /> | |
<Button | |
android:id="@+id/profile_decline_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentEnd="true" | |
android:layout_below="@+id/profile_status" | |
android:layout_marginBottom="68dp" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:background="@color/colorAccent" | |
android:padding="5dp" | |
android:paddingBottom="2dp" | |
android:paddingTop="2dp" | |
android:text="@string/decline_friend_request" | |
android:textColor="@android:color/white" | |
android:textSize="12sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.RegisterActivity"> | |
<include | |
android:id="@+id/register_toolbar" | |
layout="@layout/app_bar_layout" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/textInputLayout5" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="160dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.0" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="@string/name" /> | |
</android.support.design.widget.TextInputLayout> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/textInputLayout4" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/textInputLayout6"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="@string/password" | |
android:inputType="textPassword" /> | |
</android.support.design.widget.TextInputLayout> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/textInputLayout6" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/textInputLayout5"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="@string/e_mail" | |
android:inputType="textEmailAddress" /> | |
</android.support.design.widget.TextInputLayout> | |
<Button | |
android:id="@+id/reg_create_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="52dp" | |
android:background="@color/colorAccent" | |
android:padding="20dp" | |
android:paddingLeft="25dp" | |
android:paddingRight="25dp" | |
android:text="@string/create_account" | |
android:textColor="@android:color/white" | |
android:textSize="15sp" | |
android:textStyle="bold" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.502" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/textInputLayout4" /> | |
<TextView | |
android:id="@+id/textView2" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="8dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="45dp" | |
android:text="@string/create_a_new_account" | |
android:textColor="@android:color/black" | |
android:textSize="25sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toTopOf="@+id/textInputLayout5" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/register_toolbar" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorPrimaryDark" | |
tools:context="com.example.harsh.freechat.SettingsActivity"> | |
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/settings_dp" | |
android:layout_width="155sp" | |
android:layout_height="155sp" | |
android:layout_marginEnd="126dp" | |
android:layout_marginStart="126dp" | |
android:layout_marginTop="80dp" | |
android:src="@drawable/default_avatar" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> | |
<TextView | |
android:id="@+id/settings_name" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="30dp" | |
android:text="Display Name" | |
android:textColor="@android:color/white" | |
android:textSize="30sp" | |
android:textStyle="bold" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/settings_dp" /> | |
<TextView | |
android:id="@+id/settings_status" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginStart="8dp" | |
android:layout_marginTop="15dp" | |
android:text="Status" | |
android:textColor="@android:color/white" | |
android:textSize="20sp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/settings_name" /> | |
<Button | |
android:id="@+id/settings_image_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="77dp" | |
android:layout_marginStart="40dp" | |
android:layout_marginTop="94dp" | |
android:background="@color/colorAccent" | |
android:padding="5dp" | |
android:text="Change Image" | |
android:textColor="@android:color/white" | |
android:textSize="16sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/setting_status" /> | |
<Button | |
android:id="@+id/settings_status_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="77dp" | |
android:layout_marginEnd="40dp" | |
android:layout_marginTop="94dp" | |
android:background="@color/colorAccent" | |
android:padding="5dp" | |
android:text="Change Status" | |
android:textColor="@android:color/white" | |
android:textSize="16sp" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/setting_status" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@drawable/back2" | |
tools:context="com.example.harsh.freechat.StartActivity"> | |
<TextView | |
android:id="@+id/textView" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentTop="true" | |
android:layout_centerHorizontal="true" | |
android:layout_marginTop="113dp" | |
android:text="@string/welcome_to_freechat" | |
android:textColor="@android:color/white" | |
android:textSize="35sp" | |
android:textStyle="bold" /> | |
<Button | |
android:id="@+id/start_reg_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="55dp" | |
android:layout_alignEnd="@+id/textView" | |
android:layout_alignParentBottom="true" | |
android:layout_marginBottom="46dp" | |
android:layout_marginEnd="40dp" | |
android:background="@color/colorAccent" | |
android:padding="15dp" | |
android:text="@string/sign_up" | |
android:textColor="@android:color/white" | |
android:textSize="20sp" /> | |
<Button | |
android:id="@+id/start_login_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="55dp" | |
android:layout_alignBaseline="@+id/start_reg_btn" | |
android:layout_alignBottom="@+id/start_reg_btn" | |
android:layout_alignStart="@+id/textView" | |
android:layout_marginStart="42dp" | |
android:background="@color/colorAccent" | |
android:padding="15dp" | |
android:text="@string/log_in" | |
android:textColor="@android:color/white" | |
android:textSize="20sp" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.StatusActivity"> | |
<include | |
android:id="@+id/status_appBar" | |
layout="@layout/app_bar_layout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" /> | |
<android.support.design.widget.TextInputLayout | |
android:id="@+id/status_input" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_alignParentStart="true" | |
android:layout_below="@+id/status_appBar" | |
android:layout_marginEnd="20dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="100dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/status_appBar"> | |
<android.support.design.widget.TextInputEditText | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:hint="Your Status" /> | |
</android.support.design.widget.TextInputLayout> | |
<TextView | |
android:id="@+id/textView4" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="8dp" | |
android:layout_marginStart="20dp" | |
android:layout_marginTop="49dp" | |
android:text="Enter your Status" | |
android:textColor="@android:color/black" | |
android:textSize="25sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toTopOf="@+id/status_input" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/status_appBar" /> | |
<Button | |
android:id="@+id/update_stat_btn" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginBottom="252dp" | |
android:layout_marginEnd="45dp" | |
android:layout_marginTop="75dp" | |
android:background="@color/colorAccent" | |
android:text="Update" | |
android:textColor="@android:color/white" | |
android:textSize="18sp" | |
android:textStyle="bold" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintTop_toBottomOf="@+id/status_input" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.UsersActivity"> | |
<include layout="@layout/app_bar_layout" android:id="@+id/users_appBar"/> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/users_list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_marginTop="55dp"></android.support.v7.widget.RecyclerView> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/main_app_bar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="@color/colorPrimary" | |
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"></android.support.v7.widget.Toolbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorPrimary"> | |
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/custom_bar_image" | |
android:layout_width="36dp" | |
android:layout_height="36dp" | |
android:layout_alignParentEnd="true" | |
android:layout_alignParentTop="true" | |
android:layout_marginRight="10dp" | |
android:src="@drawable/avatar" /> | |
<TextView | |
android:id="@+id/custom_bar_title" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentStart="true" | |
android:layout_alignParentTop="true" | |
android:text="Display Name" | |
android:textColor="@android:color/white" | |
android:textSize="18sp" /> | |
<TextView | |
android:id="@+id/custom_bar_seen" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentStart="true" | |
android:layout_below="@+id/custom_bar_title" | |
android:text="Last Seen" | |
android:textColor="@android:color/white" | |
android:textSize="13sp" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.ChatsFragment"> | |
<!-- TODO: Update blank fragment layout --> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/conv_list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_alignParentStart="true"></android.support.v7.widget.RecyclerView> | |
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.FriendsFragment"> | |
<!-- TODO: Update blank fragment layout --> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/friends_list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
</android.support.v7.widget.RecyclerView> | |
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.harsh.freechat.RequestsFragment"> | |
<!-- TODO: Update blank fragment layout --> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:text="Welcome to Requests Page" /> | |
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/message_single_layout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:padding="10dp"> | |
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/message_profile_layout" | |
android:layout_width="56dp" | |
android:layout_height="56dp" | |
android:src="@drawable/avatar" /> | |
<TextView | |
android:id="@+id/message_text_layout" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/name_text_layout" | |
android:layout_marginLeft="10dp" | |
android:layout_toEndOf="@+id/message_profile_layout" | |
android:padding="0dp" | |
android:text="Message Text" | |
android:textColor="#444444" | |
android:textSize="14sp" /> | |
<TextView | |
android:id="@+id/name_text_layout" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentTop="true" | |
android:layout_marginLeft="10dp" | |
android:layout_toEndOf="@+id/message_profile_layout" | |
android:text="Display Name" | |
android:textColor="@android:color/black" | |
android:textSize="15sp" | |
android:textStyle="bold" /> | |
<ImageView | |
android:id="@+id/message_image_layout" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentEnd="true" | |
android:layout_alignStart="@+id/message_text_layout" | |
android:layout_below="@+id/message_text_layout" | |
android:layout_marginLeft="0dp" | |
android:layout_toEndOf="@+id/message_profile_layout" | |
android:padding="0dp" | |
android:scaleType="centerCrop" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="80dp"> | |
<de.hdodenhof.circleimageview.CircleImageView | |
android:id="@+id/users_single_image" | |
android:layout_width="64dp" | |
android:layout_height="64dp" | |
android:layout_marginBottom="15dp" | |
android:layout_marginLeft="15dp" | |
android:layout_marginTop="15dp" | |
android:src="@drawable/avatar" /> | |
<TextView | |
android:id="@+id/users_single_name" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignTop="@+id/users_single_image" | |
android:layout_marginStart="20dp" | |
android:layout_toEndOf="@+id/users_single_image" | |
android:text="Display Name" | |
android:textColor="@android:color/black" | |
android:textSize="18dp" /> | |
<TextView | |
android:id="@+id/users_single_status" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignBottom="@+id/users_single_image" | |
android:layout_alignStart="@+id/users_single_name" | |
android:layout_marginBottom="5dp" | |
android:text="Default Status" /> | |
<ImageView | |
android:id="@+id/user_single_online_icon" | |
android:layout_width="13dp" | |
android:layout_height="wrap_content" | |
android:layout_alignTop="@+id/users_single_name" | |
android:layout_marginBottom="35dp" | |
android:layout_marginLeft="20dp" | |
android:layout_toEndOf="@+id/users_single_name" | |
android:src="@drawable/online_icon" | |
android:visibility="invisible" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |
<background android:drawable="@mipmap/ic_launch" /> | |
<foreground android:drawable="@mipmap/ic_launch_round" /> | |
</adaptive-icon> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |
<background android:drawable="@mipmap/ic_launch" /> | |
<foreground android:drawable="@mipmap/ic_launch_round" /> | |
</adaptive-icon> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="colorPrimary">#0000aa</color> | |
<color name="colorPrimaryDark">#000077</color> | |
<color name="colorAccent">#803300</color> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="app_name">FreeChat</string> | |
<string name="welcome_to_free_chat">Welcome to Free Chat</string> | |
<string name="need_a_new_account">Need A new Account ?</string> | |
<string name="display_name">Display Name</string> | |
<string name="email">Email</string> | |
<string name="password">Password</string> | |
<string name="log_out">Log Out</string> | |
<!-- TODO: Remove or change this placeholder text --> | |
<string name="hello_blank_fragment">Hello blank fragment</string> | |
<string name="already_have_account">Already Have Account</string> | |
<string name="sign_up">Sign-up</string> | |
<string name="log_in">Log-in</string> | |
<string name="welcome">Welcome to Hi5</string> | |
<string name="welcome_to_freechat">Welcome to Freechat</string> | |
<string name="create_a_new_account">Create a New Account</string> | |
<string name="create_account">Create Account</string> | |
<string name="e_mail">E-mail</string> | |
<string name="name">Name</string> | |
<string name="send_friend_request">Send a Friend Reques</string> | |
<string name="decline_friend_request">Decline Friend Request</string> | |
<string name="current_user_status">Status</string> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment