├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── simcoder
│ │ └── tinder
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── simcoder
│ │ │ └── tinder
│ │ │ ├── Cards
│ │ │ ├── arrayAdapter.java
│ │ │ └── cards.java
│ │ │ ├── Chat
│ │ │ ├── ChatActivity.java
│ │ │ ├── ChatAdapter.java
│ │ │ ├── ChatObject.java
│ │ │ └── ChatViewHolders.java
│ │ │ ├── ChooseLoginRegistrationActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── Matches
│ │ │ ├── MatchesActivity.java
│ │ │ ├── MatchesAdapter.java
│ │ │ ├── MatchesObject.java
│ │ │ └── MatchesViewHolders.java
│ │ │ ├── RegistrationActivity.java
│ │ │ └── SettingsActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_chat.xml
│ │ ├── activity_choose_login_registration.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_matches.xml
│ │ ├── activity_registration.xml
│ │ ├── activity_settings.xml
│ │ ├── item.xml
│ │ ├── item_chat.xml
│ │ └── item_matches.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── simcoder
│ └── tinder
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 SimCoder
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tinder_android_app_clone
2 |
3 | ▷ Create an android app like tinder
4 |
5 | ▷ Full Video Tutorial Playlist here: https://www.youtube.com/playlist?list=PLxabZQCAe5fio9dm1Vd0peIY6HLfo5MCf
6 |
7 | ▷ Tools Used In this Project:
8 | - Android Studio;
9 | - Firebase:
10 | *Realtime database
11 | *Authentication
12 | - SwipeCards;
13 |
14 | ▷ In this project we've done:
15 | 1 - SwipeCards Implementation;
16 |
17 | ▷ If you have any question please ask, I'll try to answer to every question and even look at your code if that is necessary.
18 |
19 |
20 | PS: If ou're going to download the full project please use your on firebase API, the one in the project will NOT be mantained and the app may not work.
21 |
22 |
23 | # Implementation Guide
24 |
25 | **1 - Project**
26 | 1 - Open the Project in your android studio;
27 | 2 - !!!!IMPORTANT!!!! Change the Package Name. You can check how to do that here (https://stackoverflow.com/questions/16804093/android-studio-rename-package)
28 |
29 |
30 | **2 - Firebase Panel**
31 | 1 - Create Firebase Project (https://console.firebase.google.com/);
32 | 2 - import the file google-service.json into your project as the instructions say;
33 | 3 - Go to Firebase -> Registration and activate Login/Registrtion with email
34 | 4 - Go to Firebase -> storage and activate it;
35 |
36 |
37 | **!!!DONE!!!**
38 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion '26.0.2'
6 | defaultConfig {
7 | applicationId "com.simcoder.tinder"
8 | minSdkVersion 15
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | compile 'com.android.support:design:26.1.0'
30 | compile 'com.android.support:cardview-v7:26.1.0'
31 | compile 'com.android.support:support-annotations:x.x.x'
32 | compile 'com.google.firebase:firebase-core:11.0.4'
33 | compile 'com.google.firebase:firebase-database:11.0.4'
34 | compile 'com.google.firebase:firebase-auth:11.0.4'
35 | compile 'com.google.firebase:firebase-storage:11.0.4'
36 | compile 'com.github.bumptech.glide:glide:3.7.0'
37 | compile 'com.lorentzos.swipecards:library:1.0.9'
38 | testCompile 'junit:junit:4.12'
39 | }
40 |
41 |
42 |
43 | apply plugin: 'com.google.gms.google-services'
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\manel\AppData\Local\Android\sdk1/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/simcoder/tinder/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.simcoder.tinder", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Cards/arrayAdapter.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Cards;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.simcoder.tinder.R;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by manel on 9/5/2017.
18 | */
19 |
20 | public class arrayAdapter extends ArrayAdapter{
21 |
22 | Context context;
23 |
24 | public arrayAdapter(Context context, int resourceId, List items){
25 | super(context, resourceId, items);
26 | }
27 | public View getView(int position, View convertView, ViewGroup parent){
28 | cards card_item = getItem(position);
29 |
30 | if (convertView == null){
31 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.item, parent, false);
32 | }
33 |
34 | TextView name = (TextView) convertView.findViewById(R.id.name);
35 | ImageView image = (ImageView) convertView.findViewById(R.id.image);
36 |
37 | name.setText(card_item.getName());
38 | switch(card_item.getProfileImageUrl()){
39 | case "default":
40 | Glide.with(convertView.getContext()).load(R.mipmap.ic_launcher).into(image);
41 | break;
42 | default:
43 | Glide.clear(image);
44 | Glide.with(convertView.getContext()).load(card_item.getProfileImageUrl()).into(image);
45 | break;
46 | }
47 |
48 |
49 | return convertView;
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Cards/cards.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Cards;
2 |
3 | /**
4 | * Created by manel on 9/5/2017.
5 | */
6 |
7 | public class cards {
8 | private String userId;
9 | private String name;
10 | private String profileImageUrl;
11 | public cards (String userId, String name, String profileImageUrl){
12 | this.userId = userId;
13 | this.name = name;
14 | this.profileImageUrl = profileImageUrl;
15 | }
16 |
17 | public String getUserId(){
18 | return userId;
19 | }
20 | public void setUserID(String userID){
21 | this.userId = userId;
22 | }
23 |
24 | public String getName(){
25 | return name;
26 | }
27 | public void setName(String name){
28 | this.name = name;
29 | }
30 |
31 | public String getProfileImageUrl(){
32 | return profileImageUrl;
33 | }
34 | public void setProfileImageUrl(String profileImageUrl){
35 | this.profileImageUrl = profileImageUrl;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Chat/ChatActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Chat;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 |
11 | import com.google.firebase.auth.FirebaseAuth;
12 | import com.google.firebase.database.ChildEventListener;
13 | import com.google.firebase.database.DataSnapshot;
14 | import com.google.firebase.database.DatabaseError;
15 | import com.google.firebase.database.DatabaseReference;
16 | import com.google.firebase.database.FirebaseDatabase;
17 | import com.google.firebase.database.ValueEventListener;
18 | import com.simcoder.tinder.Matches.MatchesActivity;
19 | import com.simcoder.tinder.Matches.MatchesAdapter;
20 | import com.simcoder.tinder.Matches.MatchesObject;
21 | import com.simcoder.tinder.R;
22 |
23 | import java.util.ArrayList;
24 | import java.util.HashMap;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | public class ChatActivity extends AppCompatActivity {
29 | private RecyclerView mRecyclerView;
30 | private RecyclerView.Adapter mChatAdapter;
31 | private RecyclerView.LayoutManager mChatLayoutManager;
32 |
33 | private EditText mSendEditText;
34 |
35 | private Button mSendButton;
36 |
37 | private String currentUserID, matchId, chatId;
38 |
39 | DatabaseReference mDatabaseUser, mDatabaseChat;
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_chat);
44 |
45 | matchId = getIntent().getExtras().getString("matchId");
46 |
47 | currentUserID = FirebaseAuth.getInstance().getCurrentUser().getUid();
48 |
49 | mDatabaseUser = FirebaseDatabase.getInstance().getReference().child("Users").child(currentUserID).child("connections").child("matches").child(matchId).child("ChatId");
50 | mDatabaseChat = FirebaseDatabase.getInstance().getReference().child("Chat");
51 |
52 | getChatId();
53 |
54 | mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
55 | mRecyclerView.setNestedScrollingEnabled(false);
56 | mRecyclerView.setHasFixedSize(false);
57 | mChatLayoutManager = new LinearLayoutManager(ChatActivity.this);
58 | mRecyclerView.setLayoutManager(mChatLayoutManager);
59 | mChatAdapter = new ChatAdapter(getDataSetChat(), ChatActivity.this);
60 | mRecyclerView.setAdapter(mChatAdapter);
61 |
62 | mSendEditText = findViewById(R.id.message);
63 | mSendButton = findViewById(R.id.send);
64 |
65 | mSendButton.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View view) {
68 | sendMessage();
69 | }
70 | });
71 | }
72 |
73 | private void sendMessage() {
74 | String sendMessageText = mSendEditText.getText().toString();
75 |
76 | if(!sendMessageText.isEmpty()){
77 | DatabaseReference newMessageDb = mDatabaseChat.push();
78 |
79 | Map newMessage = new HashMap();
80 | newMessage.put("createdByUser", currentUserID);
81 | newMessage.put("text", sendMessageText);
82 |
83 | newMessageDb.setValue(newMessage);
84 | }
85 | mSendEditText.setText(null);
86 | }
87 |
88 | private void getChatId(){
89 | mDatabaseUser.addListenerForSingleValueEvent(new ValueEventListener() {
90 | @Override
91 | public void onDataChange(DataSnapshot dataSnapshot) {
92 | if (dataSnapshot.exists()){
93 | chatId = dataSnapshot.getValue().toString();
94 | mDatabaseChat = mDatabaseChat.child(chatId);
95 | getChatMessages();
96 | }
97 | }
98 |
99 | @Override
100 | public void onCancelled(DatabaseError databaseError) {
101 |
102 | }
103 | });
104 | }
105 |
106 | private void getChatMessages() {
107 | mDatabaseChat.addChildEventListener(new ChildEventListener() {
108 | @Override
109 | public void onChildAdded(DataSnapshot dataSnapshot, String s) {
110 | if(dataSnapshot.exists()){
111 | String message = null;
112 | String createdByUser = null;
113 |
114 | if(dataSnapshot.child("text").getValue()!=null){
115 | message = dataSnapshot.child("text").getValue().toString();
116 | }
117 | if(dataSnapshot.child("createdByUser").getValue()!=null){
118 | createdByUser = dataSnapshot.child("createdByUser").getValue().toString();
119 | }
120 |
121 | if(message!=null && createdByUser!=null){
122 | Boolean currentUserBoolean = false;
123 | if(createdByUser.equals(currentUserID)){
124 | currentUserBoolean = true;
125 | }
126 | ChatObject newMessage = new ChatObject(message, currentUserBoolean);
127 | resultsChat.add(newMessage);
128 | mChatAdapter.notifyDataSetChanged();
129 | }
130 | }
131 |
132 | }
133 | @Override
134 | public void onChildChanged(DataSnapshot dataSnapshot, String s) {
135 | }
136 | @Override
137 | public void onChildRemoved(DataSnapshot dataSnapshot) {
138 | }
139 | @Override
140 | public void onChildMoved(DataSnapshot dataSnapshot, String s) {
141 | }
142 | @Override
143 | public void onCancelled(DatabaseError databaseError) {
144 | }
145 | });
146 | }
147 |
148 |
149 | private ArrayList resultsChat = new ArrayList();
150 | private List getDataSetChat() {
151 | return resultsChat;
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Chat/ChatAdapter.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Chat;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.simcoder.tinder.R;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * Created by manel on 10/31/2017.
18 | */
19 |
20 | public class ChatAdapter extends RecyclerView.Adapter{
21 | private List chatList;
22 | private Context context;
23 |
24 |
25 | public ChatAdapter(List matchesList, Context context){
26 | this.chatList = matchesList;
27 | this.context = context;
28 | }
29 |
30 | @Override
31 | public ChatViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
32 |
33 | View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_chat, null, false);
34 | RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
35 | layoutView.setLayoutParams(lp);
36 | ChatViewHolders rcv = new ChatViewHolders(layoutView);
37 |
38 | return rcv;
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(ChatViewHolders holder, int position) {
43 | holder.mMessage.setText(chatList.get(position).getMessage());
44 | if(chatList.get(position).getCurrentUser()){
45 | holder.mMessage.setGravity(Gravity.END);
46 | holder.mMessage.setTextColor(Color.parseColor("#404040"));
47 | holder.mContainer.setBackgroundColor(Color.parseColor("#F4F4F4"));
48 | }else{
49 | holder.mMessage.setGravity(Gravity.START);
50 | holder.mMessage.setTextColor(Color.parseColor("#FFFFFF"));
51 | holder.mContainer.setBackgroundColor(Color.parseColor("#2DB4C8"));
52 | }
53 |
54 | }
55 |
56 | @Override
57 | public int getItemCount() {
58 | return this.chatList.size();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Chat/ChatObject.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Chat;
2 |
3 | /**
4 | * Created by manel on 10/31/2017.
5 | */
6 |
7 | public class ChatObject {
8 | private String message;
9 | private Boolean currentUser;
10 | public ChatObject(String message, Boolean currentUser){
11 | this.message = message;
12 | this.currentUser = currentUser;
13 | }
14 |
15 | public String getMessage(){
16 | return message;
17 | }
18 | public void setMessage(String userID){
19 | this.message = message;
20 | }
21 |
22 | public Boolean getCurrentUser(){
23 | return currentUser;
24 | }
25 | public void setCurrentUser(Boolean currentUser){
26 | this.currentUser = currentUser;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Chat/ChatViewHolders.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Chat;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 | import com.simcoder.tinder.R;
12 |
13 | /**
14 | * Created by manel on 10/31/2017.
15 | */
16 |
17 | public class ChatViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener{
18 | public TextView mMessage;
19 | public LinearLayout mContainer;
20 | public ChatViewHolders(View itemView) {
21 | super(itemView);
22 | itemView.setOnClickListener(this);
23 |
24 | mMessage = itemView.findViewById(R.id.message);
25 | mContainer = itemView.findViewById(R.id.container);
26 | }
27 |
28 | @Override
29 | public void onClick(View view) {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/ChooseLoginRegistrationActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | public class ChooseLoginRegistrationActivity extends AppCompatActivity {
10 |
11 | private Button mLogin, mRegister;
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_choose_login_registration);
16 |
17 | mLogin = (Button) findViewById(R.id.login);
18 | mRegister = (Button) findViewById(R.id.register);
19 |
20 | mLogin.setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View view) {
23 | Intent intent = new Intent(ChooseLoginRegistrationActivity.this, LoginActivity.class);
24 | startActivity(intent);
25 | finish();
26 | return;
27 | }
28 | });
29 |
30 | mRegister.setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View view) {
33 | Intent intent = new Intent(ChooseLoginRegistrationActivity.this, RegistrationActivity.class);
34 | startActivity(intent);
35 | finish();
36 | return;
37 | }
38 | });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.content.Intent;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.google.android.gms.tasks.OnCompleteListener;
13 | import com.google.android.gms.tasks.Task;
14 | import com.google.firebase.auth.AuthResult;
15 | import com.google.firebase.auth.FirebaseAuth;
16 | import com.google.firebase.auth.FirebaseUser;
17 |
18 | public class LoginActivity extends AppCompatActivity {
19 |
20 | private Button mLogin;
21 | private EditText mEmail, mPassword;
22 |
23 | private FirebaseAuth mAuth;
24 | private FirebaseAuth.AuthStateListener firebaseAuthStateListener;
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_login);
29 |
30 | mAuth = FirebaseAuth.getInstance();
31 | firebaseAuthStateListener = new FirebaseAuth.AuthStateListener() {
32 | @Override
33 | public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
34 | final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
35 | if (user !=null){
36 | Intent intent = new Intent(LoginActivity.this, MainActivity.class);
37 | startActivity(intent);
38 | finish();
39 | return;
40 | }
41 | }
42 | };
43 |
44 |
45 | mLogin = (Button) findViewById(R.id.login);
46 |
47 | mEmail = (EditText) findViewById(R.id.email);
48 | mPassword = (EditText) findViewById(R.id.password);
49 |
50 | mLogin.setOnClickListener(new View.OnClickListener() {
51 | @Override
52 | public void onClick(View view) {
53 | final String email = mEmail.getText().toString();
54 | final String password = mPassword.getText().toString();
55 | mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(LoginActivity.this, new OnCompleteListener() {
56 | @Override
57 | public void onComplete(@NonNull Task task) {
58 | if(!task.isSuccessful()){
59 | Toast.makeText(LoginActivity.this, "sign in error", Toast.LENGTH_SHORT).show();
60 | }
61 | }
62 | });
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | protected void onStart() {
69 | super.onStart();
70 | mAuth.addAuthStateListener(firebaseAuthStateListener);
71 | }
72 |
73 | @Override
74 | protected void onStop() {
75 | super.onStop();
76 | mAuth.removeAuthStateListener(firebaseAuthStateListener);
77 | }
78 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.ListView;
9 | import android.widget.Toast;
10 |
11 | import com.google.firebase.auth.FirebaseAuth;
12 | import com.google.firebase.auth.FirebaseUser;
13 | import com.google.firebase.database.ChildEventListener;
14 | import com.google.firebase.database.DataSnapshot;
15 | import com.google.firebase.database.DatabaseError;
16 | import com.google.firebase.database.DatabaseReference;
17 | import com.google.firebase.database.FirebaseDatabase;
18 | import com.google.firebase.database.ValueEventListener;
19 | import com.lorentzos.flingswipe.SwipeFlingAdapterView;
20 | import com.simcoder.tinder.Cards.arrayAdapter;
21 | import com.simcoder.tinder.Cards.cards;
22 | import com.simcoder.tinder.Matches.MatchesActivity;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | public class MainActivity extends AppCompatActivity {
28 | private cards cards_data[];
29 | private com.simcoder.tinder.Cards.arrayAdapter arrayAdapter;
30 | private int i;
31 |
32 | private FirebaseAuth mAuth;
33 |
34 | private String currentUId;
35 |
36 | private DatabaseReference usersDb;
37 |
38 |
39 | ListView listView;
40 | List rowItems;
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_main);
46 |
47 |
48 | usersDb = FirebaseDatabase.getInstance().getReference().child("Users");
49 |
50 | mAuth = FirebaseAuth.getInstance();
51 | currentUId = mAuth.getCurrentUser().getUid();
52 |
53 | checkUserSex();
54 |
55 | rowItems = new ArrayList();
56 |
57 | arrayAdapter = new arrayAdapter(this, R.layout.item, rowItems );
58 |
59 | SwipeFlingAdapterView flingContainer = (SwipeFlingAdapterView) findViewById(R.id.frame);
60 |
61 | flingContainer.setAdapter(arrayAdapter);
62 | flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() {
63 | @Override
64 | public void removeFirstObjectInAdapter() {
65 | Log.d("LIST", "removed object!");
66 | rowItems.remove(0);
67 | arrayAdapter.notifyDataSetChanged();
68 | }
69 |
70 | @Override
71 | public void onLeftCardExit(Object dataObject) {
72 |
73 | cards obj = (cards) dataObject;
74 | String userId = obj.getUserId();
75 | usersDb.child(userId).child("connections").child("nope").child(currentUId).setValue(true);
76 | Toast.makeText(MainActivity.this, "Left", Toast.LENGTH_SHORT).show();
77 | }
78 |
79 | @Override
80 | public void onRightCardExit(Object dataObject) {
81 | cards obj = (cards) dataObject;
82 | String userId = obj.getUserId();
83 | usersDb.child(userId).child("connections").child("yeps").child(currentUId).setValue(true);
84 | isConnectionMatch(userId);
85 | Toast.makeText(MainActivity.this, "Right", Toast.LENGTH_SHORT).show();
86 | }
87 |
88 | @Override
89 | public void onAdapterAboutToEmpty(int itemsInAdapter) {
90 | }
91 |
92 | @Override
93 | public void onScroll(float scrollProgressPercent) {
94 | }
95 | });
96 |
97 |
98 | // Optionally add an OnItemClickListener
99 | flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {
100 | @Override
101 | public void onItemClicked(int itemPosition, Object dataObject) {
102 | Toast.makeText(MainActivity.this, "Item Clicked", Toast.LENGTH_SHORT).show();
103 | }
104 | });
105 |
106 | }
107 |
108 | private void isConnectionMatch(String userId) {
109 | DatabaseReference currentUserConnectionsDb = usersDb.child(currentUId).child("connections").child("yeps").child(userId);
110 | currentUserConnectionsDb.addListenerForSingleValueEvent(new ValueEventListener() {
111 | @Override
112 | public void onDataChange(DataSnapshot dataSnapshot) {
113 | if (dataSnapshot.exists()){
114 | Toast.makeText(MainActivity.this, "new Connection", Toast.LENGTH_LONG).show();
115 |
116 | String key = FirebaseDatabase.getInstance().getReference().child("Chat").push().getKey();
117 |
118 | usersDb.child(dataSnapshot.getKey()).child("connections").child("matches").child(currentUId).child("ChatId").setValue(key);
119 | usersDb.child(currentUId).child("connections").child("matches").child(dataSnapshot.getKey()).child("ChatId").setValue(key);
120 | }
121 | }
122 |
123 | @Override
124 | public void onCancelled(DatabaseError databaseError) {
125 | }
126 | });
127 | }
128 |
129 | private String userSex;
130 | private String oppositeUserSex;
131 | public void checkUserSex(){
132 | final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
133 | DatabaseReference userDb = usersDb.child(user.getUid());
134 | userDb.addListenerForSingleValueEvent(new ValueEventListener() {
135 | @Override
136 | public void onDataChange(DataSnapshot dataSnapshot) {
137 | if (dataSnapshot.exists()){
138 | if (dataSnapshot.child("sex").getValue() != null){
139 | userSex = dataSnapshot.child("sex").getValue().toString();
140 | switch (userSex){
141 | case "Male":
142 | oppositeUserSex = "Female";
143 | break;
144 | case "Female":
145 | oppositeUserSex = "Male";
146 | break;
147 | }
148 | getOppositeSexUsers();
149 | }
150 | }
151 | }
152 | @Override
153 | public void onCancelled(DatabaseError databaseError) {
154 |
155 | }
156 | });
157 | }
158 |
159 | public void getOppositeSexUsers(){
160 | usersDb.addChildEventListener(new ChildEventListener() {
161 | @Override
162 | public void onChildAdded(DataSnapshot dataSnapshot, String s) {
163 | if (dataSnapshot.child("sex").getValue() != null) {
164 | if (dataSnapshot.exists() && !dataSnapshot.child("connections").child("nope").hasChild(currentUId) && !dataSnapshot.child("connections").child("yeps").hasChild(currentUId) && dataSnapshot.child("sex").getValue().toString().equals(oppositeUserSex)) {
165 | String profileImageUrl = "default";
166 | if (!dataSnapshot.child("profileImageUrl").getValue().equals("default")) {
167 | profileImageUrl = dataSnapshot.child("profileImageUrl").getValue().toString();
168 | }
169 | cards item = new cards(dataSnapshot.getKey(), dataSnapshot.child("name").getValue().toString(), profileImageUrl);
170 | rowItems.add(item);
171 | arrayAdapter.notifyDataSetChanged();
172 | }
173 | }
174 | }
175 | @Override
176 | public void onChildChanged(DataSnapshot dataSnapshot, String s) {
177 | }
178 | @Override
179 | public void onChildRemoved(DataSnapshot dataSnapshot) {
180 | }
181 |
182 | @Override
183 | public void onChildMoved(DataSnapshot dataSnapshot, String s) {
184 | }
185 | @Override
186 | public void onCancelled(DatabaseError databaseError) {
187 | }
188 | });
189 | }
190 |
191 |
192 | public void logoutUser(View view) {
193 | mAuth.signOut();
194 | Intent intent = new Intent(MainActivity.this, ChooseLoginRegistrationActivity.class);
195 | startActivity(intent);
196 | finish();
197 | return;
198 | }
199 |
200 | public void goToSettings(View view) {
201 | Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
202 | startActivity(intent);
203 | return;
204 | }
205 |
206 | public void goToMatches(View view) {
207 | Intent intent = new Intent(MainActivity.this, MatchesActivity.class);
208 | startActivity(intent);
209 | return;
210 | }
211 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Matches/MatchesActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Matches;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import com.google.firebase.auth.FirebaseAuth;
10 | import com.google.firebase.database.DataSnapshot;
11 | import com.google.firebase.database.DatabaseError;
12 | import com.google.firebase.database.DatabaseReference;
13 | import com.google.firebase.database.FirebaseDatabase;
14 | import com.google.firebase.database.ValueEventListener;
15 | import com.simcoder.tinder.R;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | public class MatchesActivity extends AppCompatActivity {
21 | private RecyclerView mRecyclerView;
22 | private RecyclerView.Adapter mMatchesAdapter;
23 | private RecyclerView.LayoutManager mMatchesLayoutManager;
24 |
25 | private String cusrrentUserID;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_matches);
31 |
32 | cusrrentUserID = FirebaseAuth.getInstance().getCurrentUser().getUid();
33 |
34 | mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
35 | mRecyclerView.setNestedScrollingEnabled(false);
36 | mRecyclerView.setHasFixedSize(true);
37 | mMatchesLayoutManager = new LinearLayoutManager(MatchesActivity.this);
38 | mRecyclerView.setLayoutManager(mMatchesLayoutManager);
39 | mMatchesAdapter = new MatchesAdapter(getDataSetMatches(), MatchesActivity.this);
40 | mRecyclerView.setAdapter(mMatchesAdapter);
41 |
42 | getUserMatchId();
43 |
44 |
45 |
46 |
47 |
48 | }
49 |
50 | private void getUserMatchId() {
51 |
52 | DatabaseReference matchDb = FirebaseDatabase.getInstance().getReference().child("Users").child(cusrrentUserID).child("connections").child("matches");
53 | matchDb.addListenerForSingleValueEvent(new ValueEventListener() {
54 | @Override
55 | public void onDataChange(DataSnapshot dataSnapshot) {
56 | if (dataSnapshot.exists()){
57 | for(DataSnapshot match : dataSnapshot.getChildren()){
58 | FetchMatchInformation(match.getKey());
59 | }
60 | }
61 | }
62 |
63 | @Override
64 | public void onCancelled(DatabaseError databaseError) {
65 |
66 | }
67 | });
68 | }
69 |
70 | private void FetchMatchInformation(String key) {
71 | DatabaseReference userDb = FirebaseDatabase.getInstance().getReference().child("Users").child(key);
72 | userDb.addListenerForSingleValueEvent(new ValueEventListener() {
73 | @Override
74 | public void onDataChange(DataSnapshot dataSnapshot) {
75 | if (dataSnapshot.exists()){
76 | String userId = dataSnapshot.getKey();
77 | String name = "";
78 | String profileImageUrl = "";
79 | if(dataSnapshot.child("name").getValue()!=null){
80 | name = dataSnapshot.child("name").getValue().toString();
81 | }
82 | if(dataSnapshot.child("profileImageUrl").getValue()!=null){
83 | profileImageUrl = dataSnapshot.child("profileImageUrl").getValue().toString();
84 | }
85 |
86 |
87 | MatchesObject obj = new MatchesObject(userId, name, profileImageUrl);
88 | resultsMatches.add(obj);
89 | mMatchesAdapter.notifyDataSetChanged();
90 | }
91 | }
92 |
93 | @Override
94 | public void onCancelled(DatabaseError databaseError) {
95 |
96 | }
97 | });
98 |
99 | }
100 |
101 | private ArrayList resultsMatches = new ArrayList();
102 | private List getDataSetMatches() {
103 | return resultsMatches;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Matches/MatchesAdapter.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Matches;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.bumptech.glide.Glide;
10 | import com.simcoder.tinder.R;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * Created by manel on 10/31/2017.
16 | */
17 |
18 | public class MatchesAdapter extends RecyclerView.Adapter{
19 | private List matchesList;
20 | private Context context;
21 |
22 |
23 | public MatchesAdapter(List matchesList, Context context){
24 | this.matchesList = matchesList;
25 | this.context = context;
26 | }
27 |
28 | @Override
29 | public MatchesViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
30 |
31 | View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_matches, null, false);
32 | RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
33 | layoutView.setLayoutParams(lp);
34 | MatchesViewHolders rcv = new MatchesViewHolders(layoutView);
35 |
36 | return rcv;
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(MatchesViewHolders holder, int position) {
41 | holder.mMatchId.setText(matchesList.get(position).getUserId());
42 | holder.mMatchName.setText(matchesList.get(position).getName());
43 | if(!matchesList.get(position).getProfileImageUrl().equals("default")){
44 | Glide.with(context).load(matchesList.get(position).getProfileImageUrl()).into(holder.mMatchImage);
45 | }
46 | }
47 |
48 | @Override
49 | public int getItemCount() {
50 | return this.matchesList.size();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Matches/MatchesObject.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Matches;
2 |
3 | /**
4 | * Created by manel on 10/31/2017.
5 | */
6 |
7 | public class MatchesObject {
8 | private String userId;
9 | private String name;
10 | private String profileImageUrl;
11 | public MatchesObject (String userId, String name, String profileImageUrl){
12 | this.userId = userId;
13 | this.name = name;
14 | this.profileImageUrl = profileImageUrl;
15 | }
16 |
17 | public String getUserId(){
18 | return userId;
19 | }
20 | public void setUserID(String userID){
21 | this.userId = userId;
22 | }
23 |
24 | public String getName(){
25 | return name;
26 | }
27 | public void setName(String name){
28 | this.name = name;
29 | }
30 |
31 | public String getProfileImageUrl(){
32 | return profileImageUrl;
33 | }
34 | public void setProfileImageUrl(String profileImageUrl){
35 | this.profileImageUrl = profileImageUrl;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/Matches/MatchesViewHolders.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder.Matches;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import com.simcoder.tinder.Chat.ChatActivity;
11 | import com.simcoder.tinder.R;
12 |
13 | /**
14 | * Created by manel on 10/31/2017.
15 | */
16 |
17 | public class MatchesViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener{
18 | public TextView mMatchId, mMatchName;
19 | public ImageView mMatchImage;
20 | public MatchesViewHolders(View itemView) {
21 | super(itemView);
22 | itemView.setOnClickListener(this);
23 |
24 | mMatchId = (TextView) itemView.findViewById(R.id.Matchid);
25 | mMatchName = (TextView) itemView.findViewById(R.id.MatchName);
26 |
27 | mMatchImage = (ImageView) itemView.findViewById(R.id.MatchImage);
28 | }
29 |
30 | @Override
31 | public void onClick(View view) {
32 | Intent intent = new Intent(view.getContext(), ChatActivity.class);
33 | Bundle b = new Bundle();
34 | b.putString("matchId", mMatchId.getText().toString());
35 | intent.putExtras(b);
36 | view.getContext().startActivity(intent);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/RegistrationActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.content.Intent;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.RadioButton;
11 | import android.widget.RadioGroup;
12 | import android.widget.Toast;
13 |
14 | import com.google.android.gms.tasks.OnCompleteListener;
15 | import com.google.android.gms.tasks.Task;
16 | import com.google.firebase.auth.AuthResult;
17 | import com.google.firebase.auth.FirebaseAuth;
18 | import com.google.firebase.auth.FirebaseUser;
19 | import com.google.firebase.database.DatabaseReference;
20 | import com.google.firebase.database.FirebaseDatabase;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | public class RegistrationActivity extends AppCompatActivity {
26 |
27 | private Button mRegister;
28 | private EditText mEmail, mPassword, mName;
29 |
30 | private RadioGroup mRadioGroup;
31 |
32 | private FirebaseAuth mAuth;
33 | private FirebaseAuth.AuthStateListener firebaseAuthStateListener;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_registration);
39 |
40 | mAuth = FirebaseAuth.getInstance();
41 | firebaseAuthStateListener = new FirebaseAuth.AuthStateListener() {
42 | @Override
43 | public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
44 | final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
45 | if (user !=null){
46 | Intent intent = new Intent(RegistrationActivity.this, MainActivity.class);
47 | startActivity(intent);
48 | finish();
49 | return;
50 | }
51 | }
52 | };
53 |
54 |
55 | mRegister = (Button) findViewById(R.id.register);
56 |
57 | mEmail = (EditText) findViewById(R.id.email);
58 | mPassword = (EditText) findViewById(R.id.password);
59 | mName = (EditText) findViewById(R.id.name);
60 |
61 | mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup);
62 |
63 | mRegister.setOnClickListener(new View.OnClickListener() {
64 | @Override
65 | public void onClick(View view) {
66 | int selectId = mRadioGroup.getCheckedRadioButtonId();
67 |
68 | final RadioButton radioButton = (RadioButton) findViewById(selectId);
69 |
70 | if(radioButton.getText() == null){
71 | return;
72 | }
73 |
74 | final String email = mEmail.getText().toString();
75 | final String password = mPassword.getText().toString();
76 | final String name = mName.getText().toString();
77 | mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(RegistrationActivity.this, new OnCompleteListener() {
78 | @Override
79 | public void onComplete(@NonNull Task task) {
80 | if(!task.isSuccessful()){
81 | Toast.makeText(RegistrationActivity.this, "sign up error", Toast.LENGTH_SHORT).show();
82 | }else{
83 | String userId = mAuth.getCurrentUser().getUid();
84 | DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
85 | Map userInfo = new HashMap<>();
86 | userInfo.put("name", name);
87 | userInfo.put("sex", radioButton.getText().toString());
88 | userInfo.put("profileImageUrl", "default");
89 | currentUserDb.updateChildren(userInfo);
90 | }
91 | }
92 | });
93 | }
94 | });
95 | }
96 |
97 | @Override
98 | protected void onStart() {
99 | super.onStart();
100 | mAuth.addAuthStateListener(firebaseAuthStateListener);
101 | }
102 |
103 | @Override
104 | protected void onStop() {
105 | super.onStop();
106 | mAuth.removeAuthStateListener(firebaseAuthStateListener);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/simcoder/tinder/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.graphics.Bitmap;
6 | import android.net.Uri;
7 | import android.provider.MediaStore;
8 | import android.support.annotation.NonNull;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.os.Bundle;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 | import android.widget.ImageView;
15 |
16 | import com.bumptech.glide.Glide;
17 | import com.google.android.gms.tasks.OnFailureListener;
18 | import com.google.android.gms.tasks.OnSuccessListener;
19 | import com.google.firebase.auth.FirebaseAuth;
20 | import com.google.firebase.auth.FirebaseUser;
21 | import com.google.firebase.database.ChildEventListener;
22 | import com.google.firebase.database.DataSnapshot;
23 | import com.google.firebase.database.DatabaseError;
24 | import com.google.firebase.database.DatabaseReference;
25 | import com.google.firebase.database.FirebaseDatabase;
26 | import com.google.firebase.database.ValueEventListener;
27 | import com.google.firebase.storage.FirebaseStorage;
28 | import com.google.firebase.storage.StorageReference;
29 | import com.google.firebase.storage.UploadTask;
30 |
31 | import java.io.ByteArrayOutputStream;
32 | import java.io.IOException;
33 | import java.util.HashMap;
34 | import java.util.Map;
35 |
36 | public class SettingsActivity extends AppCompatActivity {
37 |
38 | private EditText mNameField, mPhoneField;
39 |
40 | private Button mBack, mConfirm;
41 |
42 | private ImageView mProfileImage;
43 |
44 | private FirebaseAuth mAuth;
45 | private DatabaseReference mUserDatabase;
46 |
47 | private String userId, name, phone, profileImageUrl, userSex;
48 |
49 | private Uri resultUri;
50 |
51 | @Override
52 | protected void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | setContentView(R.layout.activity_settings);
55 |
56 | mNameField = (EditText) findViewById(R.id.name);
57 | mPhoneField = (EditText) findViewById(R.id.phone);
58 |
59 | mProfileImage = (ImageView) findViewById(R.id.profileImage);
60 |
61 | mBack = (Button) findViewById(R.id.back);
62 | mConfirm = (Button) findViewById(R.id.confirm);
63 |
64 | mAuth = FirebaseAuth.getInstance();
65 | userId = mAuth.getCurrentUser().getUid();
66 |
67 | mUserDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
68 |
69 | getUserInfo();
70 |
71 | mProfileImage.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View view) {
74 | Intent intent = new Intent(Intent.ACTION_PICK);
75 | intent.setType("image/*");
76 | startActivityForResult(intent, 1);
77 | }
78 | });
79 | mConfirm.setOnClickListener(new View.OnClickListener() {
80 | @Override
81 | public void onClick(View view) {
82 | saveUserInformation();
83 | }
84 | });
85 | mBack.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View view) {
88 | finish();
89 | return;
90 | }
91 | });
92 | }
93 |
94 |
95 | private void getUserInfo() {
96 | mUserDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
97 | @Override
98 | public void onDataChange(DataSnapshot dataSnapshot) {
99 | if(dataSnapshot.exists() && dataSnapshot.getChildrenCount()>0){
100 | Map map = (Map) dataSnapshot.getValue();
101 | if(map.get("name")!=null){
102 | name = map.get("name").toString();
103 | mNameField.setText(name);
104 | }
105 | if(map.get("phone")!=null){
106 | phone = map.get("phone").toString();
107 | mPhoneField.setText(phone);
108 | }
109 | if(map.get("sex")!=null){
110 | userSex = map.get("sex").toString();
111 | }
112 | Glide.clear(mProfileImage);
113 | if(map.get("profileImageUrl")!=null){
114 | profileImageUrl = map.get("profileImageUrl").toString();
115 | switch(profileImageUrl){
116 | case "default":
117 | Glide.with(getApplication()).load(R.mipmap.ic_launcher).into(mProfileImage);
118 | break;
119 | default:
120 | Glide.with(getApplication()).load(profileImageUrl).into(mProfileImage);
121 | break;
122 | }
123 | }
124 | }
125 | }
126 |
127 | @Override
128 | public void onCancelled(DatabaseError databaseError) {
129 |
130 | }
131 | });
132 |
133 | }
134 |
135 | private void saveUserInformation() {
136 | name = mNameField.getText().toString();
137 | phone = mPhoneField.getText().toString();
138 |
139 | Map userInfo = new HashMap();
140 | userInfo.put("name", name);
141 | userInfo.put("phone", phone);
142 | mUserDatabase.updateChildren(userInfo);
143 | if(resultUri != null){
144 | StorageReference filepath = FirebaseStorage.getInstance().getReference().child("profileImages").child(userId);
145 | Bitmap bitmap = null;
146 |
147 | try {
148 | bitmap = MediaStore.Images.Media.getBitmap(getApplication().getContentResolver(), resultUri);
149 | } catch (IOException e) {
150 | e.printStackTrace();
151 | }
152 |
153 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
154 | bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
155 | byte[] data = baos.toByteArray();
156 | UploadTask uploadTask = filepath.putBytes(data);
157 | uploadTask.addOnFailureListener(new OnFailureListener() {
158 | @Override
159 | public void onFailure(@NonNull Exception e) {
160 | finish();
161 | }
162 | });
163 | uploadTask.addOnSuccessListener(new OnSuccessListener() {
164 | @Override
165 | public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
166 | Uri downloadUrl = taskSnapshot.getDownloadUrl();
167 |
168 | Map userInfo = new HashMap();
169 | userInfo.put("profileImageUrl", downloadUrl.toString());
170 | mUserDatabase.updateChildren(userInfo);
171 |
172 | finish();
173 | return;
174 | }
175 | });
176 | }else{
177 | finish();
178 | }
179 | }
180 |
181 | @Override
182 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
183 | super.onActivityResult(requestCode, resultCode, data);
184 | if(requestCode == 1 && resultCode == Activity.RESULT_OK){
185 | final Uri imageUri = data.getData();
186 | resultUri = imageUri;
187 | mProfileImage.setImageURI(resultUri);
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
13 |
18 |
19 |
20 |
26 |
33 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_choose_login_registration.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
19 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
19 |
25 |
31 |
32 |
33 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_matches.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_registration.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
18 |
22 |
26 |
27 |
32 |
37 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
16 |
23 |
31 |
32 |
37 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
27 |
28 |
34 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_chat.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_matches.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
24 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tinder
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/simcoder/tinder/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.simcoder.tinder;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.1'
10 | classpath 'com.google.gms:google-services:3.1.0'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | google()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimCoderYoutube/TinderClone/23110d36171f749391b406bfc4d08346cdff47c6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Oct 31 11:48:23 GMT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------