Professional Documents
Culture Documents
Project Report: ST Xavier'S College of Management and Technology
Project Report: ST Xavier'S College of Management and Technology
AND TECHNOLOGY
Project Report
submitted to Aryabhata Knowledge University
for the partial fulfilment of bachelor’s in computer application
(B.C.A)
1|Page
Acknowledgment
First of all, I would like to thank the almighty god. We are so busy
in our daily lives that we fail to notice that the almighty is always
there to shower its blessings upon us. All these things would not
have been possible without his will.
2|Page
Certificate
…………………………. ……………………………….
………………………… ………………………………………
3|Page
Declaration
I, hereby declare that the work being presented in this project, titled “XO –
a social media application” as a part of course curriculum of bachelor in
Computer Application [BCA], is an authentic record of my own work
carried out under the guidance of Mr. Mukesh, Prof. in the Dept of
Computer Science, St. Xavier’s College of Management And Technology,
Patna.
4|Page
INDEX
1. Acknowledgement 2
2. Certificate 3
3. Introduction 6
4. Objective 8
5. Tools & Platform used 9
6. SRS 10
7. Flowchart 11
8. DFD 14
9. Design Document 15
10. Source code and screenshots 16
11. Testing 108
12. Limitations 109
12. Future scope 110
13. Bibliography 111
5|Page
XO – a social media application
6|Page
Why are we developing this project?
7|Page
OBJECTIVE
8|Page
TOOLS AND PLATFORM
Platform
Tools required
Android studio
firebase
Compatibility
9|Page
System Requirements & Specification (SRS)
Environment required
• RAM: 1000 MB or more.
• Storage space more than 1 GB
10 | P a g e
Flowchart
Start
Existing
New user Select user user
type
Create login
account
Chats
Welcome
page
Select user
Give to chat
introduction
logout
11 | P a g e
Display all
Features
posts friends
Chat box
Chats
settings
profile
Search
Search
friends
friend
Search
posts
With friend
Chat
Search
new friend
12 | P a g e
Image
post
video
Chat
friends
Pin
block
Delete
chat
13 | P a g e
DFD
14 | P a g e
Design
well-designed interface and screen is important to the users that’s the
window for them to view the capabilities of the system. It is the vehicle
through which many critical tasks are presented which has a direct impact
on the organization’s relation with the users.
Designing UI
15 | P a g e
Activity login
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/image_profile"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/image_profile"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:layout_centerHorizontal="true"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
16 | P a g e
android:id="@+id/username"
android:text="username"
android:maxLines="1"
android:textStyle="bold"
android:textColor="@color/design_default_color_primary_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fullName"
android:maxLines="1" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:background="@drawable/button_background"
android:id="@+id/btn_follow"
android:textColor="@color/colorPrimary"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
17 | P a g e
Main Activity
<?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=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom"
android:id="@+id/fragment_container" />
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/bottom" >
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemIconTint="@color/colorAccent"
app:labelVisibilityMode="unlabeled"
android:background="?android:attr/windowBackground"
app:menu="@menu/bottom_navigation"
18 | P a g e
android:id="@+id/bottom_navigation" />
</com.google.android.material.appbar.AppBarLayout>
</RelativeLayout>
19 | P a g e
Activity options
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context=".OptionsActivity">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
</androidx.appcompat.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_margin="8dp"
20 | P a g e
android:textColor="@color/colorPrimaryDark"
android:text="Settings"
android:id="@+id/settings" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_margin="8dp"
android:textColor="@color/colorPrimaryDark"
android:text="Log Out"
android:id="@+id/logout" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorAccent" />
21 | P a g e
Activity post
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
tools:context=".PostActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
22 | P a g e
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:src="@drawable/ic_close"
android:id="@+id/close" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POST"
android:textSize="16sp"
android:layout_marginEnd="10dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:textColor="@color/colorPrimary"
android:id="@+id/post" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
23 | P a g e
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerInside"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher"
android:id="@+id/image_added" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:hint="Description"
android:maxLines="5"
android:id="@+id/description" />
24 | P a g e
Activity register
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
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:orientation="vertical"
android:gravity="center"
android:padding="10dp"
tools:context=".RegisterActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:src="@drawable/logo" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/edit_text_background"
android:padding="10dp"
android:hint="User Name"
android:id="@+id/username" />
25 | P a g e
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:padding="10dp"
android:background="@drawable/edit_text_background"
android:hint="Full Name"
android:id="@+id/fullName" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/edit_text_background"
android:padding="10dp"
android:hint="Email"
android:inputType="textEmailAddress"
android:id="@+id/email" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/edit_text_background"
android:padding="10dp"
android:hint="Password"
android:inputType="textPassword"
android:id="@+id/password" />
26 | P a g e
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="@color/colorPrimary"
android:background="@drawable/button_background"
android:text="Register"
android:id="@+id/register" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:id="@+id/textLogin" />
</androidx.appcompat.widget.LinearLayoutCompat>
27 | P a g e
Activity start
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
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:gravity="center"
android:orientation="vertical"
android:padding="12dp"
tools:context=".StartActivity">
<!--
gravity - Standard constants and tools for placing an object within a potentially larger container
center - place the object in the center of its container in both teh vertical and horizontal
-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:src="@drawable/logo" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
28 | P a g e
android:textColor="@color/colorPrimary"
android:background="@drawable/button_background"
android:text="Log In"
android:id="@+id/login" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="@color/colorPrimary"
android:background="@drawable/button_background"
android:text="Register"
android:id="@+id/register" />
</androidx.appcompat.widget.LinearLayoutCompat>
29 | P a g e
Activity story
<?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=".StoryActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/placeholder"
android:id="@+id/image_story" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
30 | P a g e
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/reverse" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/skip" />
</LinearLayout>
<jp.shts.android.storiesprogressview.StoriesProgressView
android:layout_width="match_parent"
android:layout_height="3dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:gravity="top"
android:id="@+id/stories" >
</jp.shts.android.storiesprogressview.StoriesProgressView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/stories"
android:layout_margin="10dp" >
31 | P a g e
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:id="@+id/story_photo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/story_photo"
android:layout_margin="5dp"
android:textStyle="bold"
android:textColor="#fff"
android:textSize="15sp"
android:text="username"
android:id="@+id/story_username" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_margin="10dp"
android:padding="3dp"
32 | P a g e
android:background="#20000000"
android:id="@+id/container_seen" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_story_view" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#fff"
android:text="0"
android:id="@+id/seen_number" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="10dp
33 | P a g e
Activity story items
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="10dp" >
<RelativeLayout
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="5dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/placeholder"
android:id="@+id/story_photo" />
<de.hdodenhof.circleimageview.CircleImageView
34 | P a g e
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_story_plus"
android:id="@+id/story_plus" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:maxLines="1"
android:id="@+id/add_story_text" />
</LinearLayout>
35 | P a g e
Comments
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/image_profile" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:layout_toEndOf="@id/image_profile" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
36 | P a g e
Home
<RelativeLayout
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=".Fragment.HomeFragment">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
37 | P a g e
<ImageView
android:layout_width="180dp"
android:layout_height="35dp"
android:layout_marginLeft="-20dp"
android:layout_alignParentStart="true"
android:src="@drawable/logo" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_inbox" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bar" >
<LinearLayout
android:layout_width="match_parent"
38 | P a g e
android:layout_height="wrap_content"
android:orientation="vertical" >
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:id="@+id/recycler_view_story" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/progress_circular"
39 | P a g e
Notification
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Fragment.NotificationFragment">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
40 | P a g e
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notifications"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bar"
android:id="@+id/recycler_view" >
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout
41 | P a g e
Post details
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Fragment.PostDetailFragment">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
42 | P a g e
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:textStyle="bold"
android:text="Photo"
android:textColor="@color/colorPrimaryDark" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bar"
android:id="@+id/recycler_view" >
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
43 | P a g e
Profiles
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Fragment.ProfileFragment">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
44 | P a g e
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:maxLines="1"
android:layout_centerHorizontal="true"
android:text="username"
android:id="@+id/username" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="@drawable/ic_options"
android:id="@+id/options" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
45 | P a g e
android:layout_height="wrap_content"
android:layout_below="@id/bar" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp"
android:id="@+id/top_bar" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/image_profile" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="20dp"
android:paddingRight="4dp"
android:orientation="vertical" >
46 | P a g e
<!-- *************************************** -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:text="0"
android:id="@+id/posts" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="posts" />
</LinearLayout>
47 | P a g e
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:layout_gravity="center"
android:textSize="18sp"
android:textStyle="bold"
android:text="0"
android:id="@+id/followers" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="followers" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimaryDark"
android:layout_gravity="center"
48 | P a g e
android:textSize="18sp"
android:textStyle="bold"
android:text="0"
android:id="@+id/following" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="following" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/button_black"
android:text="edit profile"
android:id="@+id/edit_profile" />
</LinearLayout>
</LinearLayout>
<LinearLayout
49 | P a g e
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:orientation="vertical"
android:id="@+id/mid_bar" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/colorPrimaryDark"
android:text="full name"
android:id="@+id/fullName" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="5"
android:textColor="@color/colorPrimaryDark"
android:text="bio"
android:id="@+id/bio" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
50 | P a g e
android:layout_marginTop="10dp"
android:layout_marginLeft="-5dp"
android:layout_marginRight="-5dp"
android:background="@drawable/button_black"
android:orientation="horizontal"
android:id="@+id/last_bar" >
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="?android:buttonBarButtonStyle"
android:src="@drawable/ic_grid"
android:id="@+id/my_photos" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="?android:buttonBarButtonStyle"
android:src="@drawable/ic_save"
android:id="@+id/saved_photos" />
</LinearLayout>
51 | P a g e
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/recycler_view_save"
52 | P a g e
search
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Fragment.SearchFragment">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:id="@+id/bar" >
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
android:id="@+id/toolbar" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_search_light" />
53 | P a g e
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:background="@android:color/transparent"
android:hint="Search..."
android:id="@+id/search_bar" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/bar"
android:id="@+id/recyclerView" >
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
54 | P a g e
Notification 2
<?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="wrap_content"
android:layout_margin="8dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/image_profile" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:layout_toEndOf="@id/image_profile"
android:layout_toStartOf="@id/post_image" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:id="@+id/username" />
55 | P a g e
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="5"
android:id="@+id/comment" />
</LinearLayout>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:id="@+id/post_image" />
</RelativeLayout>
Photos
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
56 | P a g e
Post 2
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="15dp"
android:src="@drawable/ic_more"
android:id="@+id/more" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<de.hdodenhof.circleimageview.CircleImageView
57 | P a g e
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:id="@+id/image_profile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:id="@+id/username" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
android:id="@+id/post_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
58 | P a g e
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp" >
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_like"
android:id="@+id/like" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_comment"
android:layout_toEndOf="@+id/like"
android:layout_marginStart="10dp"
android:id="@+id/comment" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_save_black"
android:layout_alignParentEnd="true"
android:id="@+id/save" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textStyle="bold"
59 | P a g e
android:textColor="@color/colorPrimaryDark"
android:id="@+id/likes" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:id="@+id/publisher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:id="@+id/description" />
60 | P a g e
Story 2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="60dp"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_marginStart="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
app:civ_border_width="2dp"
app:civ_border_color="#f23b5a"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:src="@drawable/placeholder"
android:id="@+id/story_photo" />
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
app:civ_border_width="2dp"
app:civ_border_color="#afafaf"
android:layout_gravity="center"
android:layout_marginTop="5dp"
61 | P a g e
User
<?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="wrap_content"
android:padding="8dp" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/image_profile"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/image_profile"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:layout_centerHorizontal="true">
62 | P a g e
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/username"
android:text="username"
android:maxLines="1"
android:textStyle="bold"
android:textColor="@color/design_default_color_primary_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fullName"
android:maxLines="1" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:background="@drawable/button_background"
android:id="@+id/btn_follow"
android:textColor="@color/colorPrimary"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
63 | P a g e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".AddStoryActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
64 | P a g e
Java code for adding story
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.MimeTypeMap;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.android.gms.tasks.Continuation;
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.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ServerValue;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StorageTask;
import com.theartofdev.edmodo.cropper.CropImage;
import java.util.HashMap;
65 | P a g e
public class AddStoryActivity extends AppCompatActivity
StorageReference storageReference;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_story);
storageReference = FirebaseStorage.getInstance().getReference("Story");
CropImage.activity()
.setAspectRatio(9, 16)
.start(AddStoryActivity.this);
66 | P a g e
ContentResolver contentResolver = getContentResolver();
return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri));
progressDialog.setMessage("Posting");
progressDialog.show();
if (mImageUri != null)
storageTask = imageReference.putFile(mImageUri);
storageTask.continueWithTask(new Continuation()
@Override
if (!task.isSuccessful())
throw task.getException();
67 | P a g e
return imageReference.getDownloadUrl();
}).addOnCompleteListener(new OnCompleteListener<Uri>()
@Override
if (task.isSuccessful())
myUrl = downloadUri.toString();
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Story").child(myId);
hashMap.put("imageURL", myUrl);
hashMap.put("timeStart", ServerValue.TIMESTAMP);
hashMap.put("timeEnd", timeEnd);
hashMap.put("storyId", storyId);
68 | P a g e
hashMap.put("userId", myId);
reference.child(storyId).setValue(hashMap);
progressDialog.dismiss();
finish();
else
});
else
@Override
69 | P a g e
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode ==
RESULT_OK)
mImageUri = result.getUri();
publishStory();
else
70 | P a g e
Java code for adding comments
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.instagramclone.Adapter.CommentAdapter;
import com.example.instagramclone.Model.Comment;
import com.example.instagramclone.Model.User;
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;
71 | P a g e
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
EditText addComment;
ImageView imageProfile;
TextView post;
String postId;
String publisherId;
FirebaseUser firebaseUser;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comments);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setTitle("Comments");
72 | P a g e
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener()
@Override
finish();
});
postId = intent.getStringExtra("postId");
publisherId = intent.getStringExtra("publisherId");
recyclerView = findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(linearLayoutManager);
73 | P a g e
recyclerView.setAdapter(commentAdapter);
addComment = findViewById(R.id.add_comment);
imageProfile = findViewById(R.id.image_profile);
post = findViewById(R.id.post);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
post.setOnClickListener(new View.OnClickListener()
@Override
if (addComment.getText().toString().equals(""))
else
addComment();
});
getImage();
readComments();
74 | P a g e
}
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Comments").child(postId);
// create entry for postId for the photo that was commented on.
hashMap.put("commentId", commentId);
addComment.setText("");
addNotification();
75 | P a g e
{
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Notifications").child(publisherId);
hashMap.put("userId", firebaseUser.getUid());
hashMap.put("postId", postId);
hashMap.put("isPost", true);
reference.push().setValue(hashMap);
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
reference.addValueEventListener(new ValueEventListener()
@Override
76 | P a g e
{
// DataSnapShot instance contains data from a Firebase Database location. Anytime you read
Database data, you receive the data as a DataSnapShot.
// They are efficiently generated immutable copies of the data at a Firebase Database location.
Glide.with(getApplicationContext()).load(user.getImageURL()).into(imageProfile);
// retrieves user profile image and adds it into image_profile section for xml file.
@Override
});
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Comments").child(postId);
77 | P a g e
reference.addValueEventListener(new ValueEventListener()
@Override
commentList.clear();
// retrieves the values from Database and converts it into Comment class since the
variables for the class and the keys in database match
commentList.add(comment);
commentAdapter.notifyDataSetChanged();
@Override
});
78 | P a g e
Java code for adding profile
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.instagramclone.Model.User;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
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;
79 | P a g e
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.StorageTask;
import com.rengwuxian.materialedittext.MaterialEditText;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import java.util.HashMap;
ImageView close;
ImageView image_profile;
TextView save;
TextView textViewChange;
MaterialEditText fullName;
MaterialEditText username;
MaterialEditText bio;
FirebaseUser firebaseUser;
@Override
80 | P a g e
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
close = findViewById(R.id.close);
image_profile = findViewById(R.id.image_profile);
save = findViewById(R.id.save);
textViewChange = findViewById(R.id.textView_change);
fullName = findViewById(R.id.fullName);
username = findViewById(R.id.username);
bio = findViewById(R.id.bio);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
storageReference = FirebaseStorage.getInstance().getReference("uploads");
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
reference.addValueEventListener(new ValueEventListener()
@Override
81 | P a g e
User user = dataSnapshot.getValue(User.class);
fullName.setText(user.getFullName());
username.setText(user.getUserName());
bio.setText(user.getBio());
Glide.with(getApplicationContext()).load(user.getImageURL()).into(image_profile);
@Override
});
close.setOnClickListener(new View.OnClickListener()
@Override
finish();
});
7.
textViewChange.setOnClickListener(new View.OnClickListener()
82 | P a g e
@Override
CropImage.activity()
.setAspectRatio(1,1)
.start(EditProfileActivity.this);
});
image_profile.setOnClickListener(new View.OnClickListener()
@Override
CropImage.activity()
.setAspectRatio(1,1)
.start(EditProfileActivity.this);
});
save.setOnClickListener(new View.OnClickListener()
@Override
83 | P a g e
public void onClick(View v)
updateProfile(fullName.getText().toString(), username.getText().toString(),
bio.getText().toString());
});
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
hashMap.put("fullName", fullName);
hashMap.put("username", username);
hashMap.put("bio", bio);
reference.updateChildren(hashMap);
84 | P a g e
ContentResolver contentResolver = getContentResolver();
return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri));
progressDialog.setMessage("Uploading");
progressDialog.show();
if (mImageUri != null)
uploadTask = fileReference.putFile(mImageUri);
uploadTask.continueWithTask(new Continuation()
@Override
if (! task.isSuccessful())
throw task.getException();
85 | P a g e
}
return fileReference.getDownloadUrl();
}).addOnCompleteListener(new OnCompleteListener<Uri>()
@Override
if (task.isSuccessful())
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
reference.updateChildren(hashMap);
progressDialog.dismiss();
else
86 | P a g e
}
}).addOnFailureListener(new OnFailureListener()
@Override
});
else
@Override
mImageUri = result.get
87 | P a g e
Java code for adding profile
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.instagramclone.Model.User;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
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;
88 | P a g e
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.StorageTask;
import com.rengwuxian.materialedittext.MaterialEditText;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import java.util.HashMap;
ImageView close;
ImageView image_profile;
TextView save;
TextView textViewChange;
MaterialEditText fullName;
MaterialEditText username;
MaterialEditText bio;
FirebaseUser firebaseUser;
89 | P a g e
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
close = findViewById(R.id.close);
image_profile = findViewById(R.id.image_profile);
save = findViewById(R.id.save);
textViewChange = findViewById(R.id.textView_change);
fullName = findViewById(R.id.fullName);
username = findViewById(R.id.username);
bio = findViewById(R.id.bio);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
storageReference = FirebaseStorage.getInstance().getReference("uploads");
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
reference.addValueEventListener(new ValueEventListener()
90 | P a g e
{
@Override
fullName.setText(user.getFullName());
username.setText(user.getUserName());
bio.setText(user.getBio());
Glide.with(getApplicationContext()).load(user.getImageURL()).into(image_profile);
@Override
});
close.setOnClickListener(new View.OnClickListener()
@Override
finish();
});
91 | P a g e
// when user clicks on "change profile photo"
textViewChange.setOnClickListener(new View.OnClickListener()
@Override
CropImage.activity()
.setAspectRatio(1,1)
.start(EditProfileActivity.this);
});
image_profile.setOnClickListener(new View.OnClickListener()
@Override
CropImage.activity()
.setAspectRatio(1,1)
.start(EditProfileActivity.this);
92 | P a g e
});
save.setOnClickListener(new View.OnClickListener()
@Override
updateProfile(fullName.getText().toString(), username.getText().toString(),
bio.getText().toString());
});
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
hashMap.put("fullName", fullName);
hashMap.put("username", username);
hashMap.put("bio", bio);
93 | P a g e
reference.updateChildren(hashMap);
return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri));
progressDialog.setMessage("Uploading");
progressDialog.show();
if (mImageUri != null)
uploadTask = fileReference.putFile(mImageUri);
uploadTask.continueWithTask(new Continuation()
94 | P a g e
{
@Override
if (! task.isSuccessful())
throw task.getException();
return fileReference.getDownloadUrl();
}).addOnCompleteListener(new OnCompleteListener<Uri>()
@Override
if (task.isSuccessful())
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Users").child(firebaseUser.getUid());
95 | P a g e
else
}).addOnFailureListener(new OnFailureListener()
@Override
});
else
@Override
96 | P a g e
Java code for followers
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.renderscript.Sampler;
import android.view.View;
import com.example.instagramclone.Adapter.UserAdapter;
import com.example.instagramclone.Model.User;
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 java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
String id;
String title;
97 | P a g e
List<String> idList;
RecyclerView recyclerView;
UserAdapter userAdapter;
List<User> userList;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_followers);
id = intent.getStringExtra("id");
title = intent.getStringExtra("title");
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(title);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener()
@Override
98 | P a g e
{
finish();
});
recyclerView = findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(userAdapter);
switch(title)
case "Likes":
getLikes();
break;
case "Following":
getFollowing();
break;
case "Followers":
99 | P a g e
getFollowers();
break;
case "Views":
getViews();
break;
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Story").child(id).child(getIntent().getStringExtra("storyId"
)).child("Views");
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
idList.clear();
idList.add(snapshot.getKey());
100 | P a g e
showUsers();
@Override
});
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
idList.clear();
idList.add(snapshot.getKey());
showUsers();
101 | P a g e
@Override
});
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Follow").child(id).child("Following");
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
idList.clear();
idList.add(snapshot.getKey());
showUsers();
@Override
102 | P a g e
{
});
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Follow").child(id).child("Followers");
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
idList.clear();
idList.add(snapshot.getKey());
showUsers();
@Override
});
103 | P a g e
}
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
userList.clear();
if (user.getId().equals(id))
userList.add(user);
userAdapter.notifyDataSetChanged();
104 | P a g e
@Override
});
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
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.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
105 | P a g e
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import org.w3c.dom.Text;
EditText email;
EditText password;
Button login;
TextView textSignUp;
FirebaseAuth auth;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
login = findViewById(R.id.login);
textSignUp = findViewById(R.id.textSignUp);
auth = FirebaseAuth.getInstance();
106 | P a g e
textSignUp.setOnClickListener(new View.OnClickListener() // when user clicks on "Don't have
an account? Sign Up" TextView.
@Override
});
@Override
progressDialog.setMessage("Please wait...");
progressDialog.show();
if (TextUtils.isEmpty(emailAsString) || TextUtils.isEmpty(passwordAsString))
else
107 | P a g e
{
auth.signInWithEmailAndPassword(emailAsString,
passwordAsString).addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>()
@Override
if (task.isSuccessful())
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference().child("Users").child(auth.getCurrentUser().getUid());
reference.addValueEventListener(new ValueEventListener()
@Override
progressDialog.dismiss();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
@Override
108 | P a g e
{
});
else
progressDialog.dismiss();
});
});
109 | P a g e
Java code for main activity
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import com.example.instagramclone.Fragment.HomeFragment;
import com.example.instagramclone.Fragment.NotificationFragment;
import com.example.instagramclone.Fragment.ProfileFragment;
import com.example.instagramclone.Fragment.SearchFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
BottomNavigationView bottomNavigationView;
110 | P a g e
private BottomNavigationView.OnNavigationItemSelectedListener navigationItemSelectedListener =
new BottomNavigationView.OnNavigationItemSelectedListener()
@Override
switch (menuItem.getItemId())
case R.id.nav_home:
break;
case R.id.nav_search:
break;
case R.id.nav_add:
selectedFragment = null;
break;
case R.id.nav_heart:
break;
case R.id.nav_profile:
editor.putString("profileid", FirebaseAuth.getInstance().getCurrentUser().getUid());
editor.apply();
111 | P a g e
break;
if (selectedFragment != null)
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
selectedFragment).commit();
return true;
};
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(navigationItemSelectedListener);
112 | P a g e
// Intent describes the activity to be executed.
if (intent != null)
editor.putString("profileid", publisher);
editor.apply();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new
ProfileFragment()).commit();
else
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new
HomeFragment()).commit();
113 | P a g e
Java code for options
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;
import org.w3c.dom.Text;
TextView logout;
TextView settings;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_options);
114 | P a g e
logout = findViewById(R.id.logout);
settings = findViewById(R.id.settings);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Options");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener()
@Override
finish();
});
logout.setOnClickListener(new View.OnClickListener() {
@Override
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(OptionsActivity.this,
StartActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
});
115 | P a g e
Java code for posts
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StorageTask;
import com.theartofdev.edmodo.cropper.CropImage;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
116 | P a g e
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.HashMap;
Uri imageUri;
StorageTask uploadTask;
StorageReference storageReference;
ImageView close;
ImageView image_added;
TextView post;
EditText description;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post);
117 | P a g e
close = findViewById(R.id.close);
image_added = findViewById(R.id.image_added);
post = findViewById(R.id.post);
description = findViewById(R.id.description);
storageReference = FirebaseStorage.getInstance().getReference("Posts");
close.setOnClickListener(new View.OnClickListener()
@Override
finish();
});
post.setOnClickListener(new View.OnClickListener()
@Override
uploadImage();
});
118 | P a g e
// from image cropper library
CropImage.activity()
.setAspectRatio(1,1)
.start(PostActivity.this);
return mime.getExtensionFromMimeType(contentResolver.getType(uri));
progressDialog.setMessage("Posting");
progressDialog.show();
if (imageUri != null)
119 | P a g e
final StorageReference fileReference = storageReference.child(System.currentTimeMillis() + "." +
getFileExtension(imageUri));
uploadTask = fileReference.putFile(imageUri);
uploadTask.continueWithTask(new Continuation()
@Override
if (! task.isSuccessful())
throw task.getException();
return fileReference.getDownloadUrl();
}).addOnCompleteListener(new OnCompleteListener<Uri>()
@Override
if (task.isSuccessful())
120 | P a g e
myUrl = downloadUri.toString();
hashMap.put("postId", postId);
hashMap.put("postImage", myUrl);
hashMap.put("description", description.getText().toString());
hashMap.put("publisher", FirebaseAuth.getInstance().getCurrentUser().getUid());
reference.child(postId).setValue(hashMap);
progressDialog.dismiss();
finish();
else
121 | P a g e
}).addOnFailureListener(new OnFailureListener()
@Override
});
else
@Override
imageUri = result.getUri();
122 | P a g e
image_added.setImageURI(imageUri);
else
finish();
123 | P a g e
Java code for posts
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
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.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 org.w3c.dom.Text;
import java.util.HashMap;
124 | P a g e
public class RegisterActivity extends AppCompatActivity
EditText userName;
EditText fullName;
EditText email;
EditText password;
Button register;
TextView textLogin;
FirebaseAuth auth;
DatabaseReference reference;
ProgressDialog progressDialog;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
userName = findViewById(R.id.username);
fullName = findViewById(R.id.fullName);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
register = findViewById(R.id.register);
textLogin = findViewById(R.id.textLogin);
auth = FirebaseAuth.getInstance();
125 | P a g e
textLogin.setOnClickListener(new View.OnClickListener() // When user clicks on the "Already have
an Account? login" TextView
@Override
});
@Override
progressDialog.setMessage("Please Wait...");
progressDialog.show();
if (TextUtils.isEmpty(usernameAsString) || TextUtils.isEmpty(fullNameAsString) ||
TextUtils.isEmpty(emailAsString) || TextUtils.isEmpty(passwordAsString))
126 | P a g e
{
else
});
private void register(final String username, final String fullName, String email, String password)
auth.createUserWithEmailAndPassword(email,
password).addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>()
@Override
if (task.isSuccessful())
127 | P a g e
reference = FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
hashMap.put("id", userId);
hashMap.put("username", username.toLowerCase());
hashMap.put("fullName", fullName);
hashMap.put("bio", "");
hashMap.put("imageURL", "https://firebasestorage.googleapis.com/v0/b/instagram-
clone-ea6ff.appspot.com/o/placeholder.png?alt=media&token=68bc014d-29e3-49fa-96db-
eb9c642cf034");
reference.setValue(hashMap).addOnCompleteListener(new
OnCompleteListener<Void>()
@Override
if (task.isSuccessful())
progressDialog.dismiss();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
// the output of bitwise OR on two bits is 1 if either bit is 1, or 0 if both bits are 0.
128 | P a g e
// Intent
// Task
// - The activities are arranged in a stack (back stack) in the order in which each
activity is opened.
// - if user presses the back button, the activity that was just added us now
finished and popped off the stack.
});
else
progressDialog.dismiss();
129 | P a g e
Java code for register
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
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.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 org.w3c.dom.Text;
import java.util.HashMap;
130 | P a g e
public class RegisterActivity extends AppCompatActivity
EditText userName;
EditText fullName;
EditText email;
EditText password;
Button register;
TextView textLogin;
FirebaseAuth auth;
DatabaseReference reference;
ProgressDialog progressDialog;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
userName = findViewById(R.id.username);
fullName = findViewById(R.id.fullName);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
register = findViewById(R.id.register);
textLogin = findViewById(R.id.textLogin);
auth = FirebaseAuth.getInstance();
131 | P a g e
textLogin.setOnClickListener(new View.OnClickListener() // When user clicks on the "Already have
an Account? login" TextView
@Override
});
@Override
progressDialog.setMessage("Please Wait...");
progressDialog.show();
if (TextUtils.isEmpty(usernameAsString) || TextUtils.isEmpty(fullNameAsString) ||
TextUtils.isEmpty(emailAsString) || TextUtils.isEmpty(passwordAsString))
132 | P a g e
Toast.makeText(RegisterActivity.this, "All fields are required!",
Toast.LENGTH_SHORT).show();
else
});
private void register(final String username, final String fullName, String email, String password)
auth.createUserWithEmailAndPassword(email,
password).addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>()
@Override
if (task.isSuccessful())
reference = FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
133 | P a g e
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("id", userId);
hashMap.put("username", username.toLowerCase());
hashMap.put("fullName", fullName);
hashMap.put("bio", "");
hashMap.put("imageURL", "https://firebasestorage.googleapis.com/v0/b/instagram-
clone-ea6ff.appspot.com/o/placeholder.png?alt=media&token=68bc014d-29e3-49fa-96db-
eb9c642cf034");
reference.setValue(hashMap).addOnCompleteListener(new
OnCompleteListener<Void>()
@Override
if (task.isSuccessful())
progressDialog.dismiss();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
// the output of bitwise OR on two bits is 1 if either bit is 1, or 0 if both bits are 0.
134 | P a g e
// Intent
// Task
// - The activities are arranged in a stack (back stack) in the order in which each
activity is opened.
// - if user presses the back button, the activity that was just added us now
finished and popped off the stack.
});
else
progressDialog.dismiss();
135 | P a g e
Java code for start
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
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.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 org.w3c.dom.Text;
import java.util.HashMap;
136 | P a g e
public class RegisterActivity extends AppCompatActivity
EditText userName;
EditText fullName;
EditText email;
EditText password;
Button register;
TextView textLogin;
FirebaseAuth auth;
DatabaseReference reference;
ProgressDialog progressDialog;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
userName = findViewById(R.id.username);
fullName = findViewById(R.id.fullName);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
register = findViewById(R.id.register);
textLogin = findViewById(R.id.textLogin);
auth = FirebaseAuth.getInstance();
137 | P a g e
textLogin.setOnClickListener(new View.OnClickListener() // When user clicks on the "Already have
an Account? login" TextView
@Override
});
@Override
progressDialog.setMessage("Please Wait...");
progressDialog.show();
if (TextUtils.isEmpty(usernameAsString) || TextUtils.isEmpty(fullNameAsString) ||
TextUtils.isEmpty(emailAsString) || TextUtils.isEmpty(passwordAsString))
138 | P a g e
{
else
});
private void register(final String username, final String fullName, String email, String password)
auth.createUserWithEmailAndPassword(email,
password).addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>()
@Override
if (task.isSuccessful())
139 | P a g e
reference = FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
hashMap.put("id", userId);
hashMap.put("username", username.toLowerCase());
hashMap.put("fullName", fullName);
hashMap.put("bio", "");
hashMap.put("imageURL", "https://firebasestorage.googleapis.com/v0/b/instagram-
clone-ea6ff.appspot.com/o/placeholder.png?alt=media&token=68bc014d-29e3-49fa-96db-
eb9c642cf034");
reference.setValue(hashMap).addOnCompleteListener(new
OnCompleteListener<Void>()
@Override
if (task.isSuccessful())
progressDialog.dismiss();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
// the output of bitwise OR on two bits is 1 if either bit is 1, or 0 if both bits are 0.
140 | P a g e
// Intent
// Task
// - The activities are arranged in a stack (back stack) in the order in which each
activity is opened.
// - if user presses the back button, the activity that was just added us now
finished and popped off the stack.
});
else
progressDialog.dismiss();
141 | P a g e
Java code for story
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.instagramclone.Model.Story;
import com.example.instagramclone.Model.User;
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.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 java.lang.reflect.Array;
142 | P a g e
import java.util.ArrayList;
import java.util.List;
import jp.shts.android.storiesprogressview.StoriesProgressView;
int counter = 0;
StoriesProgressView storiesProgressView;
ImageView image;
ImageView storyPhoto;
TextView storyUsername;
List<String> images;
List<String> storyIds;
String userId;
LinearLayout containerSeen;
TextView seenNumber;
ImageView storyDelete;
143 | P a g e
private View.OnTouchListener onTouchListener = new View.OnTouchListener() // swiping up and
down on the screen
@Override
switch (event.getAction())
case MotionEvent.ACTION_DOWN:
pressTime = System.currentTimeMillis();
storiesProgressView.pause();
return false;
case MotionEvent.ACTION_UP:
storiesProgressView.resume();
return false;
};
@Override
144 | P a g e
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_story);
storiesProgressView = findViewById(R.id.stories);
image = findViewById(R.id.image_story);
storyPhoto = findViewById(R.id.story_photo);
storyUsername = findViewById(R.id.story_username);
userId = getIntent().getStringExtra("userId");
containerSeen = findViewById(R.id.container_seen);
seenNumber = findViewById(R.id.seen_number);
storyDelete = findViewById(R.id.story_delete);
containerSeen.setVisibility(View.GONE);
storyDelete.setVisibility(View.GONE);
if (userId.equals(FirebaseAuth.getInstance().getCurrentUser().getUid()))
containerSeen.setVisibility(View.VISIBLE);
storyDelete.setVisibility(View.VISIBLE);
145 | P a g e
getStories(userId);
userInfo(userId);
reverse.setOnClickListener(new View.OnClickListener()
@Override
storiesProgressView.reverse();
});
reverse.setOnTouchListener(onTouchListener);
skip.setOnClickListener(new View.OnClickListener()
@Override
storiesProgressView.skip();
146 | P a g e
}
});
skip.setOnTouchListener(onTouchListener);
containerSeen.setOnClickListener(new View.OnClickListener()
@Override
intent.putExtra("id", userId);
intent.putExtra("storyId", storyIds.get(counter));
intent.putExtra("title", "Views");
startActivity(intent);
});
storyDelete.setOnClickListener(new View.OnClickListener()
@Override
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Story").child(userId).child(storyIds.get(counter));
reference.removeValue().addOnCompleteListener(new OnCompleteListener<Void>()
147 | P a g e
@Override
finish();
});
});
@Override
Glide.with(getApplicationContext()).load(images.get(++counter)).into(image);
addView(storyIds.get(counter));
seenNumber(storyIds.get(counter));
@Override
if ((counter - 1) < 0)
return;
148 | P a g e
Glide.with(getApplicationContext()).load(images.get(--counter)).into(image);
seenNumber(storyIds.get(counter));
@Override
finish();
@Override
storiesProgressView.destroy();
super.onDestroy();
@Override
storiesProgressView.pause();
super.onPause();
149 | P a g e
@Override
storiesProgressView.resume();
super.onResume();
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
images.clear();
storyIds.clear();
150 | P a g e
if (timeCurrent > story.getTimeStart() && timeCurrent < story.getTimeEnd())
images.add(story.getImageURL());
storyIds.add(story.getStoryId());
storiesProgressView.setStoriesCount(images.size());
storiesProgressView.setStoryDuration(5000L);
storiesProgressView.setStoriesListener(StoryActivity.this);
storiesProgressView.startStories(counter);
Glide.with(getApplicationContext()).load(images.get(counter)).into(image);
addView(storyIds.get(counter));
seenNumber(storyIds.get(counter));
@Override
});
151 | P a g e
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
Glide.with(getApplicationContext()).load(user.getImageURL()).into(storyPhoto);
storyUsername.setText(user.getUserName());
@Override
});
FirebaseDatabase.getInstance().getReference("Story").child(userId).child(storyId).child("Views").child(Fir
ebaseAuth.getInstance().getCurrentUser().getUid()).setValue(true);
152 | P a g e
private void seenNumber(String storyId)
DatabaseReference reference =
FirebaseDatabase.getInstance().getReference("Story").child(userId).child(storyId).child("Views");
reference.addListenerForSingleValueEvent(new ValueEventListener()
@Override
seenNumber.setText("" + dataSnapshot.getChildrenCount());
@Override
});
8.
153 | P a g e
Home
154 | P a g e
Profile
155 | P a g e
Story
156 | P a g e
Chat
157 | P a g e
TESTING
Unit Testing
Integration Testing
158 | P a g e
Limitations
Future Scopes
• Limit the usage of the app to get rid of over usage of this
or to not get addicted
• Live to stream
• Sharing contacts through NFC (near field communication)
• Dark mode
• Inbuilt music ecosystem
159 | P a g e
CONCLUSION
160 | P a g e
BIBLIOGRAPHY
https://www.android.com/
https://developer.android.com/
https://www.behance.net/
https://dribbble.com/
https://developer.android.com/training/basics/firstapp
https://developer.android.com/studio
https://developer.android.com/guide/components/activities
161 | P a g e