Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
MDAMI committed Mar 25, 2017
1 parent 7b945c1 commit 14d1b37
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 9 deletions.
19 changes: 12 additions & 7 deletions SOLUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@

## Team details

- Team name: _`Name of your team`_
- Team name: _`GitRekt`_
- Team code: _`Code used to identify your team`_
- University: _`Your university`_
- Participant 1: _`First name Last name`_
- Participant 2: _`First name Last name`_
- University: _`Queen's University`_
- Participant 1: _`Mahad Amir`_

## Solution details

_Here, explain how the challenge went. Some examples of what we'd like to read here:_

- _What did you wanted to do at first?_
- I was hoping to implement full registration with the ability to upload your own photos
- _What did you end up doing?_
- _How did it go, overall? Do you think you have succeeded?_
- It went decently, all things considered, though I wouldn't call this a success. Working alone, on tech that I've only messed with tangentially meant that there was a steep learning curve in the first hour or so, just familiarizing myself with the environment.
- _Is there anything that **blocked** you?_
- The lack of cell signal to complete AWS Account Verification.
- _Is there anything that you are **proud of**?_
- I got farther than I thought I would.

_A couple of lines should be enough, just make sure we have a clear idea of what you did, so we can rate your **whole participation** and not just your **final result**._

### Mobile application

> **Platform choice:** _iOS or Android_
> **Platform choice:** _Android_
_Describe what you have added to the mobile project._

Currently, nothing complete.

_If your solution now requires any deployment steps other than those listed in the original `README` file, please list them here._

### Server

_Describe what you have added to the server project (if applicable)._
_Describe what you have added to the server project (if applicable)._
2 changes: 1 addition & 1 deletion android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ First, make sure you have cloned the project from Github:
git clone http://github.com/mirego/csgames17-competition.git
```

Then, in Android Studio:
Then, in Android Studio:

- Select **Import project (Eclipse, ADT, Gradle, etc.)** in the Welcome Screen, go find the `android` folder in the repository you just cloned, and click **OK**.
- Once the project is open, click on **Sync Project with Gradle Files** in the main toolbar (or navigate to `Tools -> Android` in the application menu and select the same option).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public AndroidModule(CSChatApplication application) {
Retrofit provideRetrofit() {
return new Retrofit.Builder()
// TODO: Changer pour votre propre serveur
.baseUrl("http://10.240.193.56:3000")
.baseUrl("http://10.240.201.183:3000")
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.mirego.cschat.activities;

import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.widget.EditText;

import com.mirego.cschat.R;
import com.mirego.cschat.controller.RegisterController;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
* Created by mahad on 25/03/17.
*/

public class RegisterActivity extends BaseActivity{

public static int PHOTO_SELECTED = 1;

@BindView(R.id.register_root)
ViewGroup root;

@BindView(R.id.ret_username)
EditText retUsername;

@BindView(R.id.ret_password)
EditText retPassword;

@Inject
RegisterController registerController;

ProgressDialog progressDialog;
String photoURL;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_register);
ButterKnife.bind(this);

//((CSChatApplication) getApplication()).component().inject(this);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getString(R.string.register_loading));
}

@OnClick(R.id.btn_register_submit)
void onRegisterClicked(){
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
progressDialog.show();
if(photoURL != null){

}
}

@OnClick(R.id.btn_photo)
void onPhotoClicked(){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, PHOTO_SELECTED);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == PHOTO_SELECTED){
if(resultCode == RESULT_OK){
Uri photoURI = data.getData();
photoURL = photoURI.getPath();

AmazonS3Client s3Client = new AmazonS3Client( new BasicAWSCredentials( MY_ACCESS_KEY_ID, MY_SECRET_KEY ) );

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public Flowable<User> login(String username, String password) {
return chatService.login(new LoginRequest(username, password));
}



public void logout() {
storageService.clearUserId();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.mirego.cschat.controller;

import com.mirego.cschat.models.User;
import com.mirego.cschat.models.request.RegisterRequest;
import com.mirego.cschat.services.CSChatService;
import com.mirego.cschat.services.StorageService;

import io.reactivex.Flowable;

/**
* Created by mahad on 25/03/17.
*/

public class RegisterController {
private final CSChatService chatService;
private final StorageService storageService;

public RegisterController(CSChatService chatService, StorageService storageService) {
this.chatService = chatService;
this.storageService = storageService;
}

public Flowable<User> registerPhoto(String username, String password, String photoURL) {
return chatService.registerPhoto(new RegisterRequest(username, password, photoURL));
}

public Flowable<User> registerNoPhoto(String username, String password) {
return chatService.registerNoPhoto(new RegisterRequest(username, password));
}

public void saveUserId(String userId) {
storageService.storeUserId(userId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.mirego.cschat.models.request;

/**
* Created by mahad on 25/03/17.
*/

public class RegisterRequest {
private String username;
private String password;
private String photoURL;


public RegisterRequest(String username, String password, String photoURL) {
this.username = username;
this.password = password;
this.photoURL = photoURL;
}

public RegisterRequest(String username, String password) {
this.username = username;
this.password = password;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getPhotoURL() {
return photoURL;
}

public void setPhotoURL(String photoURL) {
this.photoURL = photoURL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mirego.cschat.models.request.CreateConversationRequest;
import com.mirego.cschat.models.request.CreateMessageRequest;
import com.mirego.cschat.models.request.LoginRequest;
import com.mirego.cschat.models.request.RegisterRequest;
import com.mirego.cschat.models.response.ConversationsResponse;

import io.reactivex.Flowable;
Expand All @@ -17,6 +18,12 @@ public interface CSChatService {
@POST("api/login")
Flowable<User> login(@Body LoginRequest loginRequest);

@POST("api/users")
Flowable<User> registerPhoto(@Body RegisterRequest registerRequest);

@POST("api/users")
Flowable<User> registerNoPhoto(@Body RegisterRequest registerRequest);

@GET("api/users/{userId}/conversations")
Flowable<ConversationsResponse> fetchConversations(@Path("userId") String userId);

Expand Down
84 changes: 84 additions & 0 deletions android/app/src/main/res/layout/activity_register.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout 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:id="@+id/register_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".activities.RegisterActivity">

<TextView
android:id="@+id/tv_register"
fontPath="@string/font_lato_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/register_title"
android:textColor="@color/black"
android:textSize="30dp"
app:layout_marginTopPercent="9%" />

<android.support.design.widget.TextInputLayout
android:id="@+id/rtil_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_register"
android:hint="@string/login_username"
android:textColorHint="@color/purpleyGrey"
app:layout_marginTopPercent="10%">

<android.support.design.widget.TextInputEditText
android:id="@+id/ret_username"
style="@style/LoginField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/dustyOrange"
android:inputType="textNoSuggestions" />

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/rtil_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rtil_username"
android:hint="@string/login_password"
android:textColorHint="@color/purpleyGrey"
app:layout_marginTopPercent="4%">

<android.support.design.widget.TextInputEditText
android:id="@+id/ret_password"
style="@style/LoginField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/dustyOrange"
android:inputType="textPassword" />

</android.support.design.widget.TextInputLayout>

<Button
android:id="@+id/btn_photo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rtil_password"
android:text="@string/photo_upload"
android:theme="@style/PinkishGreyButton"
app:layout_marginTopPercent="6%"/>

<Button
android:id="@+id/btn_register_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/btn_photo"
android:text="@string/register_submit"
android:theme="@style/OrangeButton"
app:layout_marginTopPercent="6%" />


</android.support.percent.PercentRelativeLayout>
4 changes: 4 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<string name="login_username">Username</string>
<string name="login_password">Password</string>
<string name="login_submit">Continue</string>
<string name="register_title">Register</string>
<string name="register_submit">Create Account!</string>
<string name="app_name">CSChat</string>
<string name="welcome_title">Welcome to CSChat</string>
<string name="welcome_subtitle">Please login or register below.</string>
Expand All @@ -16,5 +18,7 @@
<string name="send">Send</string>
<string name="send_message_hint">Type a message...</string>
<string name="login_loading">Logging in...</string>
<string name="register_loading">Creating account</string>
<string name="not_implemented_yet">Not implemented yet!</string>
<string name="photo_upload">Upload a profile photo</string>
</resources>
22 changes: 22 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
0 info it worked if it ends with ok
1 verbose cli [ '/home/mahad/.nvm/versions/node/v6.9.4/bin/node',
1 verbose cli '/home/mahad/.nvm/versions/node/v6.9.4/bin/npm',
1 verbose cli 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: ENOENT: no such file or directory, open '/home/mahad/Projects/package.json'
4 verbose stack at Error (native)
5 verbose cwd /home/mahad/Projects/csgames17-competition
6 error Linux 4.4.9-040409-generic
7 error argv "/home/mahad/.nvm/versions/node/v6.9.4/bin/node" "/home/mahad/.nvm/versions/node/v6.9.4/bin/npm" "start"
8 error node v6.9.4
9 error npm v3.10.10
10 error path /home/mahad/Projects/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/home/mahad/Projects/package.json'
15 error enoent ENOENT: no such file or directory, open '/home/mahad/Projects/package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]
2 changes: 2 additions & 0 deletions server/data/conversations.db
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
{"users":["PHT3RCJOjHVVBZuE","PULAnPUUH06LcCzH"],"messages":[{"userId":"PULAnPUUH06LcCzH","message":"😠","timestamp":"2017-03-24T15:54:58.024Z"}],"_id":"V78SNVJ1CTpVFBa5"}
{"users":["L0Fjxv4qrNCcPkZC","ZxPI0nf1mAAp4FSM"],"messages":[{"userId":"ZxPI0nf1mAAp4FSM","message":"I’m just anonymous. I’m just alone.","timestamp":"2017-03-12T13:41:00.000Z"}],"_id":"m4aH7IpBaOgcoO3S"}
{"users":["L0Fjxv4qrNCcPkZC","PULAnPUUH06LcCzH"],"messages":[{"userId":"PULAnPUUH06LcCzH","message":"You have no business being here","timestamp":"2017-03-24T23:26:44.452Z"}],"_id":"pRfWn0jkxjQC2OEq"}
{"users":["L0Fjxv4qrNCcPkZC","PHT3RCJOjHVVBZuE"],"messages":[{"userId":"PHT3RCJOjHVVBZuE","message":"I don't know when I'm gonna die, right? So if I get hit by a truck today, then the halfway point was like 26 years ago.","timestamp":"2017-03-25T14:37:59.217Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"Pete, you're not gonna get hit by a truck.","timestamp":"2017-03-25T14:38:22.633Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"How do you know?","timestamp":"2017-03-25T14:38:34.176Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"'Cause you don't leave this building.","timestamp":"2017-03-25T14:38:48.674Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"If a truck was gonna hit you, it'd have to come in the front door.","timestamp":"2017-03-25T14:38:59.754Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"Well, that's true.","timestamp":"2017-03-25T14:39:10.144Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"Still, there's plenty of ways for a guy to die.","timestamp":"2017-03-25T14:39:17.201Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"This was a triumph","timestamp":"2017-03-25T19:12:58.495Z"}],"_id":"45otNtUdnG9K7TLo"}
{"users":["L0Fjxv4qrNCcPkZC","PHT3RCJOjHVVBZuE"],"messages":[{"userId":"PHT3RCJOjHVVBZuE","message":"I don't know when I'm gonna die, right? So if I get hit by a truck today, then the halfway point was like 26 years ago.","timestamp":"2017-03-25T14:37:59.217Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"Pete, you're not gonna get hit by a truck.","timestamp":"2017-03-25T14:38:22.633Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"How do you know?","timestamp":"2017-03-25T14:38:34.176Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"'Cause you don't leave this building.","timestamp":"2017-03-25T14:38:48.674Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"If a truck was gonna hit you, it'd have to come in the front door.","timestamp":"2017-03-25T14:38:59.754Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"Well, that's true.","timestamp":"2017-03-25T14:39:10.144Z"},{"userId":"PHT3RCJOjHVVBZuE","message":"Still, there's plenty of ways for a guy to die.","timestamp":"2017-03-25T14:39:17.201Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"This was a triumph","timestamp":"2017-03-25T19:12:58.495Z"},{"userId":"L0Fjxv4qrNCcPkZC","message":"Will this work?","timestamp":"2017-03-25T19:45:05.505Z"}],"_id":"45otNtUdnG9K7TLo"}

0 comments on commit 14d1b37

Please sign in to comment.