From 14d1b3726a8acc342c02dcb945ef9eddc8188e0b Mon Sep 17 00:00:00 2001 From: Mahad Amir Date: Sat, 25 Mar 2017 17:19:58 -0400 Subject: [PATCH] Final --- SOLUTION.md | 19 +++-- android/README.md | 2 +- .../java/com/mirego/cschat/AndroidModule.java | 2 +- .../cschat/activities/RegisterActivity.java | 85 +++++++++++++++++++ .../cschat/controller/LoginController.java | 2 + .../cschat/controller/RegisterController.java | 34 ++++++++ .../models/request/RegisterRequest.java | 47 ++++++++++ .../mirego/cschat/services/CSChatService.java | 7 ++ .../src/main/res/layout/activity_register.xml | 84 ++++++++++++++++++ android/app/src/main/res/values/strings.xml | 4 + npm-debug.log | 22 +++++ server/data/conversations.db | 2 + 12 files changed, 301 insertions(+), 9 deletions(-) create mode 100644 android/app/src/main/java/com/mirego/cschat/activities/RegisterActivity.java create mode 100644 android/app/src/main/java/com/mirego/cschat/controller/RegisterController.java create mode 100644 android/app/src/main/java/com/mirego/cschat/models/request/RegisterRequest.java create mode 100644 android/app/src/main/res/layout/activity_register.xml create mode 100644 npm-debug.log diff --git a/SOLUTION.md b/SOLUTION.md index 6bbdee7..91b970b 100644 --- a/SOLUTION.md +++ b/SOLUTION.md @@ -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)._ \ No newline at end of file +_Describe what you have added to the server project (if applicable)._ diff --git a/android/README.md b/android/README.md index 54d006c..c69432d 100644 --- a/android/README.md +++ b/android/README.md @@ -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). diff --git a/android/app/src/main/java/com/mirego/cschat/AndroidModule.java b/android/app/src/main/java/com/mirego/cschat/AndroidModule.java index 087bf0e..1f0880a 100644 --- a/android/app/src/main/java/com/mirego/cschat/AndroidModule.java +++ b/android/app/src/main/java/com/mirego/cschat/AndroidModule.java @@ -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(); diff --git a/android/app/src/main/java/com/mirego/cschat/activities/RegisterActivity.java b/android/app/src/main/java/com/mirego/cschat/activities/RegisterActivity.java new file mode 100644 index 0000000..4ce3357 --- /dev/null +++ b/android/app/src/main/java/com/mirego/cschat/activities/RegisterActivity.java @@ -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 ) ); + + } + } + } +} diff --git a/android/app/src/main/java/com/mirego/cschat/controller/LoginController.java b/android/app/src/main/java/com/mirego/cschat/controller/LoginController.java index dccf6c2..f9fa9b7 100644 --- a/android/app/src/main/java/com/mirego/cschat/controller/LoginController.java +++ b/android/app/src/main/java/com/mirego/cschat/controller/LoginController.java @@ -21,6 +21,8 @@ public Flowable login(String username, String password) { return chatService.login(new LoginRequest(username, password)); } + + public void logout() { storageService.clearUserId(); } diff --git a/android/app/src/main/java/com/mirego/cschat/controller/RegisterController.java b/android/app/src/main/java/com/mirego/cschat/controller/RegisterController.java new file mode 100644 index 0000000..9698a80 --- /dev/null +++ b/android/app/src/main/java/com/mirego/cschat/controller/RegisterController.java @@ -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 registerPhoto(String username, String password, String photoURL) { + return chatService.registerPhoto(new RegisterRequest(username, password, photoURL)); + } + + public Flowable registerNoPhoto(String username, String password) { + return chatService.registerNoPhoto(new RegisterRequest(username, password)); + } + + public void saveUserId(String userId) { + storageService.storeUserId(userId); + } +} diff --git a/android/app/src/main/java/com/mirego/cschat/models/request/RegisterRequest.java b/android/app/src/main/java/com/mirego/cschat/models/request/RegisterRequest.java new file mode 100644 index 0000000..48a397c --- /dev/null +++ b/android/app/src/main/java/com/mirego/cschat/models/request/RegisterRequest.java @@ -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; + } +} diff --git a/android/app/src/main/java/com/mirego/cschat/services/CSChatService.java b/android/app/src/main/java/com/mirego/cschat/services/CSChatService.java index 98aa5a7..864ac75 100644 --- a/android/app/src/main/java/com/mirego/cschat/services/CSChatService.java +++ b/android/app/src/main/java/com/mirego/cschat/services/CSChatService.java @@ -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; @@ -17,6 +18,12 @@ public interface CSChatService { @POST("api/login") Flowable login(@Body LoginRequest loginRequest); + @POST("api/users") + Flowable registerPhoto(@Body RegisterRequest registerRequest); + + @POST("api/users") + Flowable registerNoPhoto(@Body RegisterRequest registerRequest); + @GET("api/users/{userId}/conversations") Flowable fetchConversations(@Path("userId") String userId); diff --git a/android/app/src/main/res/layout/activity_register.xml b/android/app/src/main/res/layout/activity_register.xml new file mode 100644 index 0000000..1985016 --- /dev/null +++ b/android/app/src/main/res/layout/activity_register.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + +